Friday, February 27, 2009

C#: Open Outlook new message window

Two options:

1. System.Diagnostics.Process.Start(mailto:test@test.com?cc=test@test.com);
   
   Goto "http://www.ianr.unl.edu/internet/mailto.html" for more mailto options.

2. Add Outlook COM to project.

   Outlook.Application outlookApp = new Outlook.Application();
   Outlook.MailItem message = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
   message.Recipients.Add("someone@email.com");
   message.CC = "test@test.com";
   message.CC = "test@test.com";
   message.Subject = "subject";
   message.Body = "This is the email body.";
   message.Attachments.Add(filePath, Outlook.OlAttachmentType.olByValue, 1, "test name");
   message.Display(false);

No comments: