Solved

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

Posted on 2009-05-08
2
708 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

13 Experts available now in Live!

Get 1:1 Help Now