A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Move Mail and Se Flag Red



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 16th 06, 07:59 PM posted to microsoft.public.outlook.program_vba
achidsey
external usenet poster
 
Posts: 1
Default Move Mail and Se Flag Red


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

Ads
  #2  
Old November 1st 06, 08:06 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Move Mail and Se Flag Red

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...HV01121155.asp
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"achidsey" wrote in message ...

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

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook should make it EASIER to move the flag column. Grapevine_Tom Outlook - Installation 1 September 7th 06 10:53 PM
Move flag column SStory Outlook - General Queries 3 July 26th 06 12:51 AM
How can I move the flag icon to the front of each line? Angela Outlook - Calandaring 2 July 12th 06 04:25 PM
New mail notification should not show a red flag jader3rd Outlook - General Queries 1 May 25th 06 08:32 PM
Can not move or copy message having "flag complete" Vinayakc Add-ins for Outlook 1 February 23rd 06 04:48 PM


All times are GMT +1. The time now is 02:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.