create new from region using visual C#

D

Dinesh

hello everybody,

iam using visual c# for creating add-in for outlook 2007. my code is

Outlook.Explorer thisexplo;
Redemption.RDOMail rMail;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
thisexplo = this.Application.ActiveExplorer();
thisexplo.SelectionChange += new
Microsoft.Office.Interop.Outlook.ExplorerEvents_10_SelectionChangeEventHandler(ThisAddIn_SelectionChange);
}
void ThisAddIn_SelectionChange()
{

Outlook.MailItem mail;
mail = (Outlook.MailItem)thisexplo.Selection[1];
string ID = mail.EntryID;
Redemption.RDOSession sess = new Redemption.RDOSession();
sess.MAPIOBJECT = mail.Session.MAPIOBJECT;
rMail = sess.GetMessageFromID(ID, null, null);
string check;
check = rMail.get_Fields(0x007D001E).ToString();
int che = check.IndexOf("X-context-id");
int ch = check.IndexOf("X-Virus");
string str = check.Substring(che,ch-che);
MessageBox.Show("" + str);

it works fine. now i have to create a new region in the outlook where i can
display the str string value when i read the mail from the inbox.

Thank you.
 
K

Ken Slovak - [MVP - Outlook]

Hi,

I'd be adding try()...catch() blocks and tests for the Class of the
Selection item to make sure you are actually getting a mail item, and tests
for whether the Explorer.CurrentFolder was a mail folder. I'd also
instantiate the RDOSession object outside the SelectionChange event handler
so you don't keep instantiating instance of RDOSession.

You don't say which version of VS or VSTO you're using and the instructions
differ, but if using VS2008 then use the form region designer in VS2008/VSTO
3. If using VS2005 with VSTO 2005 SE then download the sample addins from
the Office Online Web site and take a look at how they create form regions.
The TravelAgencyAddinCS_VSTO is a good one for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top