c# 調用outlook發送郵件

  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;
        }






發佈了68 篇原創文章 · 獲贊 14 · 訪問量 17萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章