Oliver D.
Posts: 54
Joined: 2005-02-03
|
How can I get the new mail entries from the mail inspector by clicking on a custom button BEFORE sending the mail?
Like:
- Open new mail inspector
- enter TO, SUBJECT, BODY, etc.
- Click Custom Button
- Now, read all those information in popup dialog
- Then send the mail.
Thanks guys.
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Hi Oliver. Try the following code:
Outlook._MailItem mail = null;
Outlook._Inspector inspector = OutlookHost().ActiveInspector();
try
{
if (inspector.CurrentItem is Outlook._MailItem)
{
mail = inspector.CurrentItem as Outlook._MailItem;
string TO = mail.To;
string SUBJECT = mail.Subject;
string BODY = mail.Body;
}
}
finally
{
if (inspector != null)
Marshal.ReleaseComObject(inspector);
if (mail != null)
Marshal.ReleaseComObject(mail);
}
|
|
Oliver D.
Posts: 54
Joined: 2005-02-03
|
Thank you Sergey.
I used ActiveExplorer instead of ActiveInspector. Duhh!
Thank you so much AGAIN for all your excellent support!
Your premium support is worth every penny!!
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
Oliver, this is the code with ActiveExplorer.
object item = null;
Outlook._MailItem mail = null;
Outlook.Selection selection = null;
Outlook._Explorer explorer = OutlookHost().ActiveExplorer();
try
{
selection = explorer.Selection;
if (selection != null)
{
if (selection.Count > 0)
{
item = selection.Item(1);
if (item is Outlook._MailItem)
{
mail = item as Outlook._MailItem;
string TO = mail.To;
string SUBJECT = mail.Subject;
string BODY = mail.Body;
}
}
}
}
finally
{
if (item != null)
Marshal.ReleaseComObject(item);
if (selection != null)
Marshal.ReleaseComObject(selection);
if (mail != null)
Marshal.ReleaseComObject(mail);
if (explorer != null)
Marshal.ReleaseComObject(explorer);
}
|
|
Oliver D.
Posts: 54
Joined: 2005-02-03
|
That's what I used previously realizing that I should have used the ActiveInspector instead of ActiveExplorer in my code. The "Duhh!" was for myself. :-)
Thanks again. |
|