C#應用CDO發送郵件的辦法。本站提示廣大學習愛好者:(C#應用CDO發送郵件的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#應用CDO發送郵件的辦法正文
本文實例講述了C#應用CDO發送郵件的辦法。分享給年夜家供年夜家參考。詳細剖析以下:
CDO是一個名為Microsoft CDO For Exchange 2000 Library的COM組件,我們可以用它來銜接SMTP Server,應用用戶名/暗碼驗證發送郵件。
/** * C# Programmers Pocket Consultant * Author: Gregory S. MacBeth * Email: [email protected] * Create Date: June 27, 2003 * Last Modified Date: * Version: 1 */ using System; using CDO; using ADODB; namespace Client.Chapter_19___Office_Integration { public class UsingCDOEx { static void Main(string[] args) { Message MyMessage = new MessageClass(); Configuration MyConfig = MyMessage.Configuration; Fields MyFields = MyConfig.Fields; MyFields[@"http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2; MyFields[@"http://schemas.microsoft.com/cdo/configuration/smtpserverport"].Value = 25; MyFields[@"http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = "smarthost"; MyFields.Update(); MyMessage.Configuration = MyConfig; MyMessage.TextBody = "This is a test message"; MyMessage.Subject = "Testing"; MyMessage.From = "[email protected]"; MyMessage.To = "[email protected]"; MyMessage.Send(); } } }
願望本文所述對年夜家的C#法式設計有所贊助。