newbie46
asked on
How do I retrieve the color flag of an Outlook email using Access 2007 vba?
I am using the following code to read emails from Outlook:
Private Sub ImportEmails_Click()
Dim olApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim mItem As MailItem
Dim InboxItems As Outlook.Items
On Error GoTo Err_ImportEmails_Click
Set olApp = CreateObject("Outlook.Appl ication")
Set Inbox = olApp.GetNamespace("Mapi") .GetDefaul tFolder(ol FolderInbo x).Folders ("xxx").Fo lders("yyy ")
Set InboxItems = Inbox.Items
For Each mItem In InboxItems
'Check email flag
'If Flag = Yellow then
'EmailAssignedTo="Sue"
'elseif Flag = Red then
'EmailAssignedTo = "Bob"
'end if
.
Next
I need to add code which will determine the color of the email flag, to incorporate the if statements above, which are commented out.
How is the color of the email flag accessed?
I have found information on using OlCategoryColor, but have not been able to successfully incorporate this into the code.
Private Sub ImportEmails_Click()
Dim olApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim mItem As MailItem
Dim InboxItems As Outlook.Items
On Error GoTo Err_ImportEmails_Click
Set olApp = CreateObject("Outlook.Appl
Set Inbox = olApp.GetNamespace("Mapi")
Set InboxItems = Inbox.Items
For Each mItem In InboxItems
'Check email flag
'If Flag = Yellow then
'EmailAssignedTo="Sue"
'elseif Flag = Red then
'EmailAssignedTo = "Bob"
'end if
.
Next
I need to add code which will determine the color of the email flag, to incorporate the if statements above, which are commented out.
How is the color of the email flag accessed?
I have found information on using OlCategoryColor, but have not been able to successfully incorporate this into the code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Chris,
I was able to solve the problem using mItem.Categories to access the name associated with the color coded email, so I didn't have to bother with the color.
Thanks.
I was able to solve the problem using mItem.Categories to access the name associated with the color coded email, so I didn't have to bother with the color.
Thanks.
ASKER
Thanks for your response. FlagIcon is not an option in the dropdown displayed after typing mitem. Do I need to access FlagIcon through another avenue?
I have attached a screen shot of the options that are visible from mitem.
mItemOptions.doc