Manage incoming messages

M

mike lade

I desperatly need your help. I need to check the smtp address of all
incoming mail messages Outlook 2000 (MAPI, exchange sever).
If it contains "@x.com", then I would like to move it to a folder called
"SPAM"...

I tried many sample code, but I am not able to make it all work...

If the folder doesn't exist, how can I create it?

Also, is it possible to check the items that are already in the inbox
and move those that contain "@x.com"...


Thank you very much for your help. I appreaciate it.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
E

Eric Legault [MVP - Outlook]

First off, to get the SMTP address see
http://www.outlookcode.com/d/code/getsenderaddy.htm.

If you expect a specific folder to exist in a MAPIFolder.Folders collection,
check to see if the folder object variable is valid when you retrieve it.

i.e.
Set objFolder = objThisFolder.Folders("SPAM")
If not objFolder Is Nothing Then
'do something
End If

To get the messages in the Inbox, use this:

Dim objNS As Outlook.NameSpace
Dim objInbox As Outlook.MAPIFolder, objItems As Outlook.Items, objItem
As Object

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)

For Each objItem In objInbox.Items
'work with the objItem object
Next
 
Top