Web Analytics Made Easy -
StatCounter Automatic Detection of Mail Status in Outlook using MAPI - CodingForum

Announcement

Collapse
No announcement yet.

Automatic Detection of Mail Status in Outlook using MAPI

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatic Detection of Mail Status in Outlook using MAPI

    Hi To All,

    Is there a way in MAPI or others to detect that the mail status is changed, like read or unread.

    I want to make a program that runs as a service and a portion of a code will get executed once the current user clicks on an email from his outlook. Like for example when he reads a new email, he will need to click on subject so the new status of the email is changed to "READ" from the time he clicks on the subject a portion of my program will run.

    Is it possible? And can you show me a bit on how to do that?

    Any ideas is greatly appreciated.

    Thanks so much.

    -Jan Jerell

  • #2
    I find a solution:

    Code:
                Outlook.Application objO = new Outlook.Application();
                Outlook.NameSpace objNS = objO.GetNamespace("mapi");
                objNS.Logon("PROFILENAME", "PASSWORD", true, false);
                Outlook.Folder objFolder = (Outlook.Folder)objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
                objFolder.Items.ItemChange +=new Microsoft.Office.Interop.Outlook.ItemsEvents_ItemChangeEventHandler(Items_ItemChange);
    
    
            void Items_ItemChange(object Item)
            {
    
                Outlook.MailItem item = (Outlook.MailItem)Item;
    
                if(item.UnRead) 
                {
                  //Email is not yet read
                }
                else
                {
                     //Email is read
                }
    
            }

    Comment

    Working...
    X