Solved

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

Posted on 2009-05-08
2
718 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 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