To use Outlook add a COM reference to Outlook library. Here's a sample of
opening a mail item and setting some properties. It exposes an
Attachments.Add property but I have not tested it.
private void OutlookMail(string Subject, string Body)
{
Outlook.ApplicationClass app = new Outlook.ApplicationClass();
Outlook.NameSpaceClass ns = (NameSpaceClass)app.GetNamespace("mapi");
ns.Logon("", "", true, true);
Outlook.MailItem mi =
(Outlook.MailItem)app.CreateItem(Outlook.OlItemType.olMailItem);
mi.Subject = Subject;
mi.HTMLBody = Body;
mi.Display(1); // show it non - modally
app = null;
ns.Logoff();
ns = null;
mi = null;
}
To use the default mail client you can simply execute a mailto: URI.
System.Diagnostics.Process.Start(string.Format("mailto:{0}?Subject={1}&Body=
{2}", To, Subject, Body));
You can also access the System.Web.Mail instead of using Outlook or find a
SMAPI wrapper (
http://www.codeproject.com/csharp/simplemapidotnet.asp). As
usual, each method has pros and cons, so check them out and see which fits
best for your needs.
Problems I can recall:
SMAPI - didn't see a way to set HTML format. Doesn't show up in Sent Items.
System.Web.MailMessage - doesn't open a window to set To and From address,
would have to set in code or get input from user.
Outlook - Requires that you reference a COM dll. Distribution issues for
rich client.
URL: No attachments, length of URL limited to 255. Cannot invoke Send.
Be sure to do lots of testing as virus protection or windows security may
try to block you.
HTH,
Eric Cadwell
http://www.origincontrols.com