We will be looking into how to insert a signature in an outlook email whenever an end user compose a new email.
We will be basically creating an Outlook Inspector for the new mail and then after few validations will be inserting a signature through manipulating the Email HtmlBody.
Declare the inspector
Trapping the Application.Inspectors.NewInspector and adding a event handler to it in ThisAddin_StartUp.
private void ThisAddIn_Startup(object sender, System.EventArgs e)
olInspectors = this.Application.Inspectors;
olInspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(My_NewInspector);
Adding the event Handler:
void My_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
if (mailItem != null)
if (mailItem.EntryID == null)
mailItem.HTMLBody = “Thanks & Regards,<br/> Nitin Rawat <br/> <a style=’text-decoration: none’ href=’https://nitinasp.wordpress.com/’>Blog</a> “;
A newly composed mail does not have a EntryID but a sent mail have a EntryID so this check is placed to enter the signature only when the mail is new.
We can perform a large set of operations in the My_NewInspector method depending on our need.