1.首先,勾選outlook組件
《1》右擊工程文件的Reference,選擇Add Reference。
《2》點擊.net tab, 選擇Microsoft.Office.Interop.Outlook.dll,點擊 OK。
2. 添加引用:
using Outlook = Microsoft.Office.Interop.Outlook;
3. 代碼如下;
<pre name="code" class="csharp">public void Emailconfig()
{
Outlook.Application olApp = new Outlook.Application();
Outlook.MailItem mailItem = (Outlook.MailItem)olApp.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.To = "[email protected]";
mailItem.Subject = "郵件標題";
mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
string content = "嗨,all:<br/> <br/>大家好,blablablabla郵件正文<br/> <br/>";
mailItem.HTMLBody = content;
((Outlook._MailItem)mailItem).Send();
mailItem = null;
olApp = null;
}