我正在使用.NET 3.5,我想自動發送郵件。我目前使用下列內容:用C發送電子郵件#
Microsoft.Office.Interop.Outlook.MailItem mailMsg =
(Microsoft.Office.Interop.Outlook.MailItem)outlookApplication.CreateItem(
Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
mailMsg.To = recipient;
mailMsg.Subject = subject;
mailMsg.Body = body;
mailMsg.Send();
不過,我發現了幾個文章,似乎在暗示我應該使用下面的方法:
System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage();
mailmsg.To = recipient;
mailmsg.Subject = subject;
mailmsg.Body = body;
誰能告訴我有什麼區別兩個命名空間如果,以及爲什麼你可能想要使用另一個命名空間?
另外值得注意的是,實例化outlook的開銷並不是微不足道的。 – Paddy 2010-05-28 11:51:57