對於選項(1)準備處理Outlook版本問題。但是,這並不難(再次,如果我們談論的是Outlook中,最後一個版本)自動支持請求我計劃在我的當前項目「微軟企業日誌支持塊」的電子郵件發送功能使用
//using Microsoft.Office.Interop.Outlook;
private void OutlookMail(string Subject, string Body)
{
ApplicationClass app = new ApplicationClass();
NameSpaceClass ns = (NameSpaceClass)app.GetNamespace("mapi");
ns.Logon("", "", true, true);
MailItem mi =
(MailItem)app.CreateItem(OlItemType.olMailItem);
mi.Subject = Subject;
int EOFPos = Body.IndexOf(char.Parse("\0"));
if (EOFPos != -1)
{
log.Error("EOF found in Mail body");
ErrorDialog ed = new ErrorDialog(TietoEnator.Common.ErrorDialog.ErrorDialog.Style.OK, "Export Error", "File could not be exported correctly, please inform responsible person", "", "EOF char detected in the body of email message.");
ed.ShowDialog();
Body=Body.Replace("\0", "");
}
mi.HTMLBody = "<html><head><META content='text/html; charset=CP1257' http-equiv=Content-Type></head><body><table>"+Body+"</table></body></html>";
mi.BodyFormat = OlBodyFormat.olFormatHTML;//.olFormatPlain;
mi.Display(0); // show it non - modally
ns.Logoff();
}
BTW 。
您可以使用System.Net.Mail對象發送郵件,請參閱http://www.systemnetmail.com以獲取更多信息。不確定在選項上推薦什麼。 – 2010-11-20 19:46:15
@布萊恩:我認爲這是選項3) – 2010-11-20 19:52:04