Move send mails from special account

L

lau.freddy

Hy together,

im getting really mad with VBA in Outlook 2003.

Im trying to check when a mail has been send from which account it was
send. After that I want to move the sent mail in a special folder if
the sender is ....

Im trying it with this code....

Option Explicit
Public WithEvents SentItems As Outlook.Items
Private Sub Application_Startup()
Set SentItems = _
Outlook.Session.GetDefaultFolder(olFolderSentMail).Items
End Sub
Private Sub Application_Quit()
Set SentItems = Nothing
End Sub
Private Sub SentItems_ItemAdd(ByVal Item As Object)
Select Case Item.From
Case "(e-mail address removed)" ' folder1
Item.Move
Outlook.Session.GetDefaultFolders(olFolderInbox).Folders("TEST")
Case "(e-mail address removed)" ' folder2
Item.Move
Outlook.Session.GetDefaultFolders(olFolderInbox).Folders("TEST2")
Case Else ' Leave it in the top Inbox
Item.Move Outlook.Session.GetDefaultFolders(olFolderInbox)
End Select
End Sub

Can someone help me please!!! Thanks really for any suggestion....
 
S

Sue Mosher [MVP-Outlook]

The object browser -- F2 in VBA -- is your friend. If you looked at the properties for MailItem, you'd see there is no From property but there is a SenderEmailAddress.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Spidergate

Hy,

thanks for your quick answer.... :)) It seems that I really need to
learn how VBA Scripting is working... I can´t get that thing to
work....

Can you do me a favour an give me the complete string of the script....
Thanks an best regards
 
S

Sue Mosher [MVP-Outlook]

All you should need to do is change Item.From to Item.SenderEmailAddress. IF that doesn't work, make sure you've taken care of the basics listed at http://www.outlookcode.com/d/vbabasics.htm, put in a breakpoint, and step through the code.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Hy,

thanks for your quick answer.... :)) It seems that I really need to
learn how VBA Scripting is working... I can´t get that thing to
work....

Can you do me a favour an give me the complete string of the script....
Thanks an best regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top