An unexpected CDO. Message Error

Source: Internet
Author: User
Tags mailmessage

A few months ago, I wrote a serviceMSMQSent from the message sending GroupProgram, And there is no time for testing. If you try it today, an error is reported when you send an email. The exception is as follows:

 

"System. Web. httpexception: failed to access the" CDO. Message "object. ---> System. reflection. targetinvocationexception: The call Target has an exception. ---> System. runtime. interopservices. comexception (0x80040211): the email cannot be sent to the SMTP server. Transmission ErrorCode0x80040217. The server response is not available \ r \ n.--- End of the internal exception stack trace --- \ r \ n

 

The related code is as follows:

Smtpmail. smtpserver = smtpserver;

Mailmessage = new mailmessage ();

Mailmessage. Subject = mailsubject;

Mailmessage. From = mailfrom;

Mailmessage. bodyformat = mailformat. html;

Mailmessage. Body = mailbody;

Smtpmail. Send (mailmessage );

 

Will such a simple code also go wrong? I wrote one now. Webform The Code passes the test. Well. Isn't it possible to write services? Now Google To one copy Yan Xiaojun Solutions: When sending an email, exceptions may occur: failed to access the "CDO. Message" object. , Hey ... And me! After unremitting efforts, I got the following answer:

 

After the same process, the problem is still as old;The reason remains to be studied in person! :(

 

As far as I know, this smtpserver does not have a verification mechanism,WebformAlso passed, the permissions assigned by the entire system are also given, and in multiple environments (Win2000, win2003).,I did not try it. Simply find a domain account and try again. Add the following three lines of code:

 

Mailmessage. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ","1");

Mailmessage. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", @ "×× \ ×× ");

Mailmessage. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendpassword", "×× ");

 

Test result: pass! Boring....

 

The smtpserver does not have a verification mechanism, but the error "CDO. Message" is reported without verification? Unreasonable. modify the code again, remove the user and password, and specify the defaultSMTPThe authentication parameter is"0", The Code is as follows:

Mailmessage. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ","0");

 

Test result: pass!

 

although the Code passes, but still do not understand, why winform email CDO. what are the default parameters for message authentication?

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.