.NET WINFORM中使用本地SMTP SERVICE
發表于:2007-06-30來源:作者:點擊數:
標簽:
這兩天做了一個小PROJECT,大致是一個SERVER監控系統,如果發現某部SERVER有異常,發送EMAIL到相關手機,以便在非工作時間和節假日也能及時知道系統故障。 其中一個功能就是發送EMAIL。程序是這樣的: myMailMsg.To = "888888888@mobile.att.net"; myMailMsg
這兩天做了一個小PROJECT,大致是一個SERVER監控系統,如果發現某部SERVER有異常,發送EMAIL到相關手機,以便在非工作時間和節假日也能及時知道系統故障。
其中一個功能就是發送EMAIL。程序是這樣的:
myMailMsg.To = "888888888@mobile.att.net";
myMailMsg.From = "support@medicalit.net";
myMailMsg.Subject = "server down";
myMailMsg.Body = "Please call StarLan to chen Database Server";
myMailMsg.BodyFormat = MailFormat.Text;
SmtpMail.SmtpServer="localhost";
SmtpMail.Send(myMailMsg);
本來是用外部的SMTP SERVER
SmtpMail.SmtpServer="smtp.XXX.com";
但后來發現由于DATA CENTER的FIREWALL原因,改用
SmtpMail.SmtpServer="localhost";
運行后系統提示錯誤信息:
Email Fail
Could not A
clearcase/" target="_blank" >ccess 'CDO.Message' object.
Here is the full error message output:
System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x8004020F): The server rejected one or more recipient addresses. The server response
was: 550 5.7.1 Unable to relay for 12321323@mobile.att.net
檢查SMTP SERVICE,正常,估計是權限設置問題。打開IIS AD
MIN,右鍵點擊SMTP VIRTUAL SERVER(默認SMTP虛擬
服務器),選擇屬性,在A
CCESS(訪問)中點RELAY(中繼),增加127.0.0.1。一路OK回去。
這時候再運行程序,郵件發送成功。
原文轉自:http://www.kjueaiud.com