|
-
Jul 25th, 2001, 03:13 PM
#1
Thread Starter
Lively Member
Outlook automation problem
I am trying to write an automation that will delete the deleted files in the deleted items folder in outlook.....
Here is the code.
Private Sub Command1_Click()
Dim objOutlook As New Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objInbox As MAPIFolder
Dim objMail As MailItem
'Get the MAPI reference
Set objNameSpace = objOutlook.GetNamespace("MAPI")
'Pick up the Inbox
Set objInbox = objNameSpace.GetDefaultFolder(olFolderDeletedItems)
'Loop through the folders under the Inbox
For Each objMail In objInbox.Items
objMail.Delete
Next objMail
End Sub
I get a code error when it gets to a certain part in the folder....
Type mismatch - error 13
-
Jul 25th, 2001, 03:14 PM
#2
Member
-
Jul 25th, 2001, 03:17 PM
#3
Thread Starter
Lively Member
Next objMail
The problem is in the loop......i think
-
Jul 25th, 2001, 03:35 PM
#4
Thread Starter
Lively Member
Some times it's on the for each statment
-
Jul 25th, 2001, 03:50 PM
#5
Thread Starter
Lively Member
Figured it out take away Dim objMail As MailItem
and add
Set objMail = objOutlook.CreateItem(olMailItem)
That will take care of it.....My problem now is that it stops for some reason.....
-
Jul 25th, 2001, 04:15 PM
#6
Thread Starter
Lively Member
Halfway through deleting all of the e-mails it drops out of the loop.....
Is there something wrong with my loop?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|