Reference to the mailitem the user has chosen

  • Thread starter Thread starter neoret
  • Start date Start date
N

neoret

Hi there :)

I have a button in Outlook which allows the user to save a mail item to
an external archiving system.

If the user presses this button I need to check wether or not he has a
mail-item "active". By this I mean that the user has selected a mail in
a spesific folder that he wants to archive.

Furthermore I need to get hold of that spesific mail item with
belonging attachements.

When reading in documentations, articles and examples I can only see
how you create folders and items - not how to get a reference to an
existing one.

I write my code in C#, and has a shared add-in. This button is
displayed in every office-application.

Thank's a lot for any contribution :)
 
ActiveExplorer is the active object in a folder view. Selected items in
ActiveExplorer are in the Selection collection. Once you have the item you
can access all its properties and its attachments.

Something like this:

private Outlook.Selection colSelect;
private Outlook.MailItem m_mail;

if (this.Application.ActiveExplorer() != Null)
{
colSelect = this.Application.ActiveExplorer().Selection;

try
{
m_mail = (Outlook.MailItem) colSelect[1];
// whatever
}
catch
{
}

// whatever
}
 
Back
Top