Outlook Add-in

B

BrassicaNigra

I have created a ribbon add-in for Outlook 2007. It is programmed to show
up when an email is in the read frame (ribbonID ==
"Microsoft.Outlook.Mail.Read"). It shows up and the OnClick event handler
works just fine.

When this button is clicked the add-in will pass an email address to another
application.

My problem is I don't know how to reference the item that is currently being
read in the Read pane. I followed the instructions at the following link to
get started.

http://msdn.microsoft.com/en-us/library/bb756875.aspx

Following is my OnClick handler function.

public void OnClick(Office.IRibbonControl control)
{
Application = Globals.ThisAddIn.Application;
Outlook.Folder inBox =
(Outlook.Folder)Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MailItem miCurrent = (Outlook.MailItem)inBox.Items[5];
String strTo = miCurrent.To.ToString();
}

As you can see where I initialize miCurrent that I can get what I need when
the array index is hardwired (inBox.Items[5]), I just want to know what the
index value is for the item being displayed in the window in which the ribbon
appears.

Thank you for your help.
 
J

Jialiang Ge [MSFT]

Good morning Brassica

If you meant the "Reading Pane" in Outlook's main explorer, we could get
the item by using AcitveExplorer.Selection. Here is an example:

Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
if (explorer != null && explorer.Selection != null &&
explorer.Selection.Count > 0)
{
Outlook.MailItem mail = explorer.Selection[1] as Outlook.MailItem;
if (mail != null)
{
MessageBox.Show(mail.To);
}
}

If you meant the mail item that is currently opened in the active
inspector, where our add-in resides. We can get it by using
AciveInspector.CurrentItem. Here is an example:

Outlook.Inspector inspector =
Globals.ThisAddIn.Application.ActiveInspector();
Outlook.MailItem item = inspector.CurrentItem as Outlook.MailItem;
if (item != null)
{
MessageBox.Show(item.To);
}

Please try the above and let me know whether they are helpful to you. If
you have any other questions or concerns, DON'T hesitate to tell me.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
B

BrassicaNigra

One last thing. How do I (or can I) control the image displayed in this
button. I found that the imageMso propertie could be set to 'HappyFace' and
that a little smiley face would appear at the top of the button.

I would like to use a graphic that covers the button like the native ones in
MS Office.

Is there an article or reference somewhere that will help me with this?

Thanks again for all your help.
 
S

Scott McPhillips [MVP]

BrassicaNigra said:
One last thing. How do I (or can I) control the image displayed in this
button. I found that the imageMso propertie could be set to 'HappyFace'
and
that a little smiley face would appear at the top of the button.

I would like to use a graphic that covers the button like the native ones
in
MS Office.

Is there an article or reference somewhere that will help me with this?


This download displays and names all of them:
<http://www.microsoft.com/downloads/...25-93E8-4ED4-8385-74D0F7661318&displaylang=en>
 
J

Jialiang Ge [MSFT]

Thank you very much, Scott!

Brassica, please try the download in Scott's reply and let us know whether
it helps you.

Thanks,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
B

BrassicaNigra

Thank you both for your help. All of this worked very well. No more
questions (at least for now).
 

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