none
how to get new incoming mail id in Outlook on NewMailEventHandler event . RRS feed

  • Question

  • Hi all,

    Please help me to achieve new incoming mail ID from Outlook .Whenever a new mail come i just want to know the new incoming mail id ..

    Please help me friends ......

    Wednesday, December 4, 2013 12:19 PM

Answers

  • Hello Sohan,

    This NewMail event fires when one or more new mail messages arrive in the Inbox. It doesn't give us any access to the mail or mails that arrived. If you receive 16 or more items at once, the event does not even fire. So, the event doesn't provide any info about the arriving emails.

    Instead you can use the NewMailEx event of the application class. It provides a collection of just arrived items entry IDs.  For example:

    void MyApplication_NewMailEx(string anEntryID)
    {
      Outlook.NameSpace namespace = this.GetNamespace("MAPI");  
      Outlook.MAPIFolder folder = this.Session.GetDefaultFolder( Outlook.OlDefaultFolders.olFolderInbox );
      Outlook.MailItem mailItem = (Outlook.MailItem) outlookNS.GetItemFromID( anEntryID, folder.StoreID );
    
      // ... process the mail item
    }
    Note, the NewMailEx event fires when a new message arrives in the Inbox and  before client rule processing occurs.
    Wednesday, December 4, 2013 1:19 PM