How to create Outlook email item using C# and vb.net

The following code example demonstrates how to create a new Outlook e-mail item with the specified information such as To, subject or body.
In this example we will create a new Outlook email item and display. The following code sample requires a reference of ‘Microsoft.Office.Interop.Outlook’ library in your project.

create Outlook email item using C-sharp

You can also Specify the level of importance for a created mail item by setting the mailItem.Importance property. You can set the following enum values to the mailItem.

olImportanceLow    Item is marked as low importance.
olImportanceNormal   Item is marked as medium importance.
olImportanceHigh   Item is marked as high importance.

[VB.net]

Private Sub CreateMailItem()
        Dim oApp As Outlook.Application = New Outlook.Application
        Dim mailItem As Outlook.MailItem = oApp.CreateItem(Outlook.OlItemType.olMailItem)
        mailItem.Subject = "This is the test message"
        mailItem.To = "contactus@authorcode.com"
        mailItem.CC = "supporttools@authorcode.com"
        mailItem.Body = "This is the test message"
        mailItem.Importance = Outlook.OlImportance.olImportanceNormal
        mailItem.Display(False)
        mailItem = Nothing
        oApp = Nothing
    End Sub

 
[C#]

private void CreateMailItem()
{
	Outlook.Application oApp = new Outlook.Application();
	Outlook.MailItem mailItem =(Outlook.MailItem) oApp.CreateItem(Outlook.OlItemType.olMailItem);
	mailItem.Subject = "This is the test message";
	mailItem.To = "contactus@authorcode.com";
	mailItem.CC = "supporttools@authorcode.com";
	mailItem.Body = "This is the test message";
	mailItem.Importance = Outlook.OlImportance.olImportanceNormal;
	mailItem.Display(false);
	mailItem = null;
	oApp = null;
}