Solved

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

Posted on 2009-05-08
2
710 Views
Last Modified: 2013-11-10
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?



0
Comment
Question by:WebGeeksUnlimited
  • 2
2 Comments
 
LVL 1

Author Comment

by:WebGeeksUnlimited
ID: 24349937
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

0
 
LVL 1

Accepted Solution

by:
WebGeeksUnlimited earned 0 total points
ID: 24349961
I should mention, that surveyURI is set by the ribbondropdown selection change event elsewhere, but grabs the Tag property value.
 

private void dpnSurveys_SelectionChanged(object sender, RibbonControlEventArgs e)

        {

            selectedItemURL = dpnSurveys.SelectedItem.Tag.ToString();

        }

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now