This project has moved and is read-only. For the latest updates, please go here.

Open Outlook with Email typed-in (draft) instead of sending directly

Jun 22, 2011 at 2:05 PM
Edited Jun 22, 2011 at 2:13 PM

Hi! I wanted to know if there is a way to 'send' email to Outlook instead of directly 'sending through' Outlook.

using Outlook = NetOffice.OutlookApi;

...

// Create an Outlook Application object. 
Outlook.Application outlookApplication = new Outlook.Application();

// Create a new MailItem.
Outlook.MailItem mailItem = outlookApplication.CreateItem(OlItemType.olMailItem) as Outlook.MailItem;

...

mailItem.Send();

Also, I don't want to quit Outlook through my code. If I use 'outlookApplication.Dispose();', this should only allow GC to re-claim the object but the Outlook would still be running... right?

My requirements are that once I transpose the grids and stuff to HTML, I need to manually generate the HTML body for the email and add 'To' and 'CC' and then fire up Outlook and present the final email to the user. He/She send at his/her convenience. The Email needs to be a Draft-like as the use may wants to add further information to it.

Is it possible using NetOffice Suite?

Jun 22, 2011 at 2:45 PM

sure, outlookApplication.Dispose() release the application COM Proxy and all created child proxies but outlook is still alive after Dispose();
please keep in your mind, netoffice is 1:1 wrapper, all what is possible with vba or interop its also possible in netoffice with same syntax.
i'm not sure that i'm understand your question but i think you want display the mail item and not send. look at the last line of the following code:

// Create a new MailItem.
Outlook.MailItem mailItem = outlookApplication.CreateItem(OlItemType.olMailItem) as Outlook.MailItem;
          
// prepare item 
mailItem.Recipients.Add("ballmer@microsoft.com");
mailItem.CC = "bill@microsoft.com";
mailItem.Subject = "cloud computing is bullshit";
mailItem.Body = "rename software on demand to cloud computing is a dirty marketing trick.";

// display the item
mailItem.Display();

regards
sebastian


 

 

Jun 22, 2011 at 3:05 PM

Excellent. I found `.Save()` before your reply. My issue is now a tissue.