Archive for the ‘VSTO’ Category

VSTO: Outlook - Add a contact programmatically – in C#

Here goes the code:

folder = this.Application.Session
.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
 
Outlook.ContactItem ci = (ContactItem)folder
.Items.Add(OlItemType.olContactItem);
ci.FirstName = "xyz";
[...]

Leave a Comment

How to add a button to Outlook Standard toolbar

Here goes a quick code. You need to write your own button removal code This uses VSTO - for Office 2007

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Office.CommandBar cbar
= Application.ActiveExplorer().CommandBars["Standard"];
 
Office.CommandBarButton btn
= (Office.CommandBarButton)cbar.Controls.Add(Office.MsoControlType.msoControlButton,
Type.Missing, Type.Missing, Type.Missing, true);
 
btn.Click +=new Microsoft.Office.Core.
_CommandBarButtonEvents_ClickEventHandler(btn_Click);
 
}
 
 
private void btn_Click(CommandBarButton Ctrl,
ref bool CancelDefault)
{
MessageBox.Show("Clicked me!");
}

VN:F [1.1.6_502]Rating: 0.0/5 (0 votes cast)

Leave a Comment