The local SMTP service (CDO) is used in. NET WinForm. Message error handling)

Source: Internet
Author: User
Tags error handling
smtp| Error | Error handling the two days did a small project, roughly a server monitoring system, if found in a certain server abnormal, send email to the relevant mobile phone, so that in time and holidays can also be aware of the system failure.


One of the functions is to send email. The procedure is this:


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


was originally used with an external SMTP SERVER


Smtpmail.smtpserver= "SMTP. XXX.com ";


But later found that because of the firewall reason for data center, instead


smtpmail.smtpserver= "localhost";


Post-run system prompts for error messages:


Email Fail
Could not access ' CDO. Message ' object.
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 a 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


Checking the SMTP SERVICE is normal, and is estimated to be a permission setting issue. Open IIS ADMIN, right-click SMTP virtual server (Default SMTP VM), select Properties, relay (relay) in Access (access), and increase 127.0.0.1. OK go back all the way.


Then run the program and the message is sent successfully.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.