日期:2013-08-20 浏览次数:20401 次
其中一个功能就是发送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 access ''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 ADMIN,右键点击SMTP VIRTUAL SERVER(默认SMTP虚拟服务器),选择属性,在ACCESS(访问)中点RELAY(中继),增加127.0.0.1。一路OK回去。
这时候再运行程序,邮件发送成功。