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

Macro code to add Catergory Colour to Mail.



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 25th 10, 06:25 AM
CamP CamP is offline
Junior Member
 
First recorded activity at Outlookbanter: Oct 2010
Posts: 2
Default Macro code to add Catergory Colour to Mail.

Hi,

I have 4 existing macros which forward the selected email from the inbox to 1 of 4 pre-set email accounts when run. I would like to include code into these macros that marks the emails in the inbox with a category colour so i can see which items have been forwarded to which 1 of the 4 pre-set email accounts e.g. Blue Category, Red Category, Yellow Category and Green Category. I have played around with objMail.Categories and objMail.Save without any success. I hope somebody can assist. My existing Macro code is:

Sub EmailFoward()
Dim objMail As Outlook.MailItem
Set objItem = GetCurrentItem()
Set objMail = objItem.Forward
objMail.To = "email account"
objMail.Send
Set objItem = Nothing
Set objMail = Nothing
End Sub

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = _
objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = _
objApp.ActiveInspector.CurrentItem
Case Else
End Select
End Function

Thanks. (Running Outlook 2007).

Last edited by CamP : October 25th 10 at 08:01 AM.
Ads
  #2  
Old November 4th 10, 05:27 AM
CamP CamP is offline
Junior Member
 
First recorded activity at Outlookbanter: Oct 2010
Posts: 2
Default

Hi,

For those who might be interested I have solved my problem.

I added a new category under Outlook called "test" and allocated it a colour.

I also added this code into my existing Macro:

Call MarkWithCategory("test")

and

Sub MarkWithCategory(strCat As String)

Dim objItem As Object
Set objItem = GetCurrentItem()
If Not objItem Is Nothing Then
objItem.Categories = objItem.Categories & "," & strCat
objItem.Save
End If
Set objItem = Nothing

End Sub

Hope this assists somebody.
 




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
Add the macro in new mail form masani paresh[_2_] Outlook - Using Forms 1 December 24th 08 03:22 PM
How do I colour code emails from hotmail? Joan Mary Outlook - General Queries 5 June 28th 08 12:07 PM
Colour code from different servers Pete A Outlook - General Queries 3 June 16th 07 03:06 PM
Colour code outlook contacts perthkat Outlook - Using Contacts 1 April 26th 06 08:30 AM
How do I colour-code meeting req. for shared users on a network? Revelfree Outlook - Calandaring 0 March 15th 06 11:16 AM


All times are GMT +1. The time now is 05: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.