Move Mail and Se Flag Red

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
 
S

Sue Mosher [MVP-Outlook]

1) Set objItem to the current e-mail which is highlighted.

Application.ActiveExplorer.Selection(1) returns the first highlighted ittem.
2) Set objDestinationFolder - I'm not sure how to specify a folder

To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm and, especially for public folders, http://www.outlookcode.com/codedetail.aspx?id=1164

3) Set the flag of the item in its original folder to red

The object browser is your friend. Take a look at the MailItem.FlagIcon property - http://msdn.microsoft.com/library/en-us/vbaol11/html/olproFlagIcon1_HV01121155.asp
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

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

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