Link to home
Start Free TrialLog in
Avatar of WebGeeksUnlimited
WebGeeksUnlimited

asked on

VS2008 VSTO Outlook 2007 working with a in progress composed message body

I working on a Addin project in C#, where I've created a ribbon type Microsoft.Outlook.Mail.Compose.

The ribbon item has a dropdown that is populated from a database of surveys that are associated with a URL (stored in the dropdown item TAG property). I want to insert into the message they are composing if they click the insert button.

I can't seem to find how to do this in C# to drop the URL of the selected dropdown item TAG property contents into the message body and hopfully where the cursor is currently located (if that is possible).

The ribbon appears OK at this point and the dropdown is populated OK, now I just need to get the dropdown item TAG property value into the message body.

How do I do this?



Avatar of WebGeeksUnlimited
WebGeeksUnlimited

ASKER

After some trial and error, I figure out something that works. I also found that you can't insert where the current cursor is located unfortunately.
Referencing the ActiveInspector().CurrentItem will give you access to the open window, i my case the compose window.
 
 

                // Get a reference to the current object opened
                Microsoft.Office.Interop.Outlook.MailItem mail = (Microsoft.Office.Interop.Outlook.MailItem)new Microsoft.Office.Interop.Outlook.ApplicationClass().ActiveInspector().CurrentItem as Microsoft.Office.Interop.Outlook.MailItem;
                if (!(mail == null))
                {
                    // Insert at the begining of the message
                    mail.Body = (surveyURI.ToString() + ("\r\n" + mail.Body));
                }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of WebGeeksUnlimited
WebGeeksUnlimited

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial