A
achidsey
Outlook Experts,
I am new to Outlook Programmming having worked before with Excel VBA.
In Outlook, I highlight an e-mail, read it in the window, and then copy it
to another folder. After I've copied it to the other folder, I change the
flag to a red color. I want to write a macro that will automate this.
The folder that the e-mail is moved to is Public Folders\All Public
Folders\OP's\Derivatives\OTC Derivatives\Fish & Nadl
I gave the code a try based on a book and looking at some other posts.
Three things I didn't know how to do:
1) Set objItem to the current e-mail which is highlighted.
2) Set objDestinationFolder - I'm not sure how to specify a folder
3) Set the flag of the item in its original folder to red
Below is the code I came up with. I'd appreciate help in fixing the three
above issues and any other problems I may have created.
Thanks, Alan
Sub MoveEmailToFish()
Dim ObjApp As Outlook.Application
Dim ObjNS As Outlook.NameSpace
Dim objItem As Object
Dim objDestinationFolder As Outlook.MAPIFolder
Set ObjApp = CreateObject("Outlook.Application")
Set ObjNS = ObjApp.GetNamespace("MAPI")
'Set objItem = (Current E-mail)?
'Set objDestinationFolder = _
objNS.Folders("Public Folders\All Public Folders\OP's\Derivatives\OTC
DERIVATIVES\FISH & NADL")
objItem.Copy objDestinationFolder
'objItem.olRedFlagIcon
Set ObjApp = Nothing
Set ObjNS = Nothing
Set objItem = Nothing
End Sub
I am new to Outlook Programmming having worked before with Excel VBA.
In Outlook, I highlight an e-mail, read it in the window, and then copy it
to another folder. After I've copied it to the other folder, I change the
flag to a red color. I want to write a macro that will automate this.
The folder that the e-mail is moved to is Public Folders\All Public
Folders\OP's\Derivatives\OTC Derivatives\Fish & Nadl
I gave the code a try based on a book and looking at some other posts.
Three things I didn't know how to do:
1) Set objItem to the current e-mail which is highlighted.
2) Set objDestinationFolder - I'm not sure how to specify a folder
3) Set the flag of the item in its original folder to red
Below is the code I came up with. I'd appreciate help in fixing the three
above issues and any other problems I may have created.
Thanks, Alan
Sub MoveEmailToFish()
Dim ObjApp As Outlook.Application
Dim ObjNS As Outlook.NameSpace
Dim objItem As Object
Dim objDestinationFolder As Outlook.MAPIFolder
Set ObjApp = CreateObject("Outlook.Application")
Set ObjNS = ObjApp.GetNamespace("MAPI")
'Set objItem = (Current E-mail)?
'Set objDestinationFolder = _
objNS.Folders("Public Folders\All Public Folders\OP's\Derivatives\OTC
DERIVATIVES\FISH & NADL")
objItem.Copy objDestinationFolder
'objItem.olRedFlagIcon
Set ObjApp = Nothing
Set ObjNS = Nothing
Set objItem = Nothing
End Sub