0 votes

I've downloaded the trial and most parts are working well but before I purchase I need to ensure I can create a new IMail object, insert custom headers then open the item in outlook for final editing before sending.

Do you know if this is possible? - I've tried searching your site but can't find any sample code.

by (8.8k points)

1 Answer

0 votes

Here's the code to add custom header and save the email message on disk:

MailBuilder builder = new MailBuilder();
builder.From.Add(new MailBox("alice@mail.com", "Alice"));
builder.To.Add(new MailBox("bob@mail.com", "Bob"));
builder.Subject = "Test";
builder.Text = "This is plain text message.";

builder.AddCustomHeader("x-key","value");

IMail email = builder.Create();
email.Save("c:\\email.eml");

Each .eml file can be opened inside MS Outlook for viewing (supported by Outlook 2003 and above).

It is enough to set the Outlook to be default email client and double click to the .eml file to open it. That will not import EML file to Outlook.

To transfer .eml file you should drag the email file to any Outlook folder and the drop it (release the mouse button). Outlook will open dragged email message and you will be able to save it inside desired folder.

In Microsoft Office Outlook 2007 you may need to install this hotfix:
http://support.microsoft.com/kb/956693/en

by (297k points)
...