Microsoft Office Tutorials and References
In Depth Information
Creating a Ribbon menu for Outlook 2007
6. To create a program that will open a window for composing a new mail on
a button click event, write the following code snippet inside the Ribbon1.cs
file. Also include the code using Microsoft.Office.Interop.Outlook; in
the Ribbon1.cs file to get access to the Outlook objects.
// Click event of the button
private void Button_OpenNewMail_Click(object sender,
RibbonControlEventArgs e)
{
// Application class to get Outlook object references
ApplicationClass PacktApplication = new ApplicationClass();
// Get the MAPIFolder NameSpaces
NameSpace PacktNameSpace = PacktApplication.
GetNamespace("MAPIFolder");
// Access to the default folders
MAPIFolder ApreeMAPI = PacktNameSpace.
GetDefaultFolder(OlDefaultFolders.olFolderInbox);
// Outlook mailitem object to compose new mail
MailItem PacktMailItem = (MailItem)ApreeMAPI.Items.
Add(OlItemType.olMailItem);
// To display the new mail compose window
PacktMailItem.Display(true);
}
 
Search JabSto ::




Custom Search