How to Program Outlook 2007 Add-In with Multiple Mailboxes

I'm trying to figure how to write a simple add-in for Excel 2007, but one that only interacts with one of my mailboxes. Currently I have two email addresses coming into my outlook, each in a specific 'mailbox'. I was wondering, how would I specify a NewMail event for a specific mailbox?

Or, perhaps not as clean, but how could I write an if function that specifies which mailbox / email any new item is addressed to...

Hopefully this makes sense. Thanks


To catch new mail event, add this code to addin startup method:

this.Application.NewMailEx += 
    new Outlook.ApplicationEvents_11_NewMailExEventHandler(Application_NewMailEx);

Then add method to handle NewMailEx event:

void Application_NewMailEx(string EntryID)
    // get MailItem for this new mail
    Outlook.Explorers explorers = this.Application.Explorers;
    Outlook.MailItem newMail =
        (Outlook.MailItem)explorers.Application.Session.GetItemFromID(EntryID, System.Reflection.Missing.Value);

    // check SendUsingAccount to see if it came in mailbox we are interested in
    if (newMail.SendUsingAccount.DisplayName == "")
        // do whatever You like

Add using statement also:

using Outlook = Microsoft.Office.Interop.Outlook;  

Need Your Help

need a random word generator using a dictionary

objective-c ios xcode ios5

I'm making a hangman game, so I need a random word generator. My goal is for the user to say how many letters they want in the word and to output a random word with that many letters. I would like ...

Making handleFileupload with parameter to share the methode

java jsf primefaces managed-bean

I'm using fileuplod primefaces. I have 3 buttons. Every button is responsible for uploading a file. My first steep is to use 3 methods on my bean to upload every file.

Check if username exists using PHP PDO

php mysql pdo

How do I check if a username exists using PDO? All I need to know is a bool true (exists) or false (does not). I have the initial parts set up but am unsure what to do next