Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing a copy of an email to a specified Outlook folder upon sending 1

Status
Not open for further replies.

thumper808

Technical User
Apr 22, 2001
26
CA
Hi Guys...I think I have a pretty simple question but I'm not sure about Outlook VBA.
I just need to place a copy of an email, once sent (when the SEND button is pressed), to a folder that the user specifies. I have the following but I am very new to Outlook VBA. Could someone point me in the right direction please? I have the following code...

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objMailItem As Outlook.MailItem
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder

End sub
 
You first need to declare and instantiate a MAPI folter object. Then execute the .Move method of the Mail object, identifying the Folder to move to.
Code:
Dim lObj_MoveToFolder As MAPIFolder
Set lObj_MoveToFolder = Me.GetNamespace("MAPI").Folders.Item(<Mailbox Name>).Folders(<Folder Name>)
objMailItem.Move lObj_MoveToFolder


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
You rock CajunCenturion! That definetely works well for me. Thank you for your answer! Tek-tips has never let me down. Have a great day!
 
Thank you thumper808, and the best to you as well.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top