How do I retrieve the color flag of an Outlook email using Access 2007 vba?

Posted on 2012-08-23
Last Modified: 2012-10-06
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.Application")

Set Inbox = olApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox).Folders("xxx").Folders("yyy")

Set InboxItems = Inbox.Items
For Each mItem In InboxItems

'Check email flag
'If Flag = Yellow then
'elseif Flag = Red then
'EmailAssignedTo = "Bob"
'end if

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.
Question by:newbie46
    LVL 59

    Accepted Solution

    via mitem.flagicon

    if mitem.FlagIcon = olRedFlagIcon then ...


    Author Comment

    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.

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Sorry for my English and Italian screenshots..... Problem: Every Year the number of E-Mails grow dramatically and the space that they take on Exchange Servers or .PST files, grow much more faster, once it was only text, now our E-Mail Archives …
    Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now