90% use exchange mail management developed by WebDAV (5) -- the remaining 10% is used for sending emails

Source: Internet
Author: User
90% exchange mail management developed using WebDAV (5)
-- The remaining 10% is used for sending emails.

In the above article, I know the basic format of the mail, but I still have no way to use WebDAV to construct an email with an attachment. Although the basic idea is as follows: UseCodeGenerate randomBoundaryString, and then convert the uploaded file to base64 encoding, and attach it to the email. However, the attempt was unsuccessful. Later, I found on a blog that I needed to construct a text email body. Then I sent an email and asked, but no response was received. It should be because my English is too bad. This is the only time I did not reply to my questions like a foreigner. Unlike a VIP, The remoting client commissionedArticleThe example does not run at all, (basically none of the Code that allows deserialization) and does not return emails.

1. send an email
Finally, we use CDO for this part, so the title is 90%. The process is as follows:
1. Add a reference to the CDO component.
2. Code:

Try
{
CDO. messageclass mail = New CDO. messageclass ();
Mail. = This . TBTO. text;
Mail. CC = This . Tbcc. text;
Mail. bcc = This . Tbbcc. text;
Mail. Subject = This . Tbsubject. text;
Mail. From = User. Identity. Name;
Mail. textbody = This . Freetextbox1.text;

String Userid = User. Identity. Name. Trim ();
String Strpassword = Dal. Data. usermodel. selectbyuserid (userid). Password. Trim ();

String [] Filename = This . Tbattachment. value. tostring (). Split ( New   Char [] {','} );
Foreach ( String S In Filename)
{
If (S ! = String. Empty)
{
Mail. addattachment (server. mappath ("Mailattachment/"+S), userid, strpassword );
}
}
Mail. Send ();
Response. Write ( " <SCRIPT> alert (\ " Email sent successfully \ " ) </SCRIPT> " );
}
Catch (Exception ex)
{
Response. Write ("<SCRIPT> alert (\""+ Ex. Message +"\") </SCRIPT>");
}

This Code does not have any problems during debugging, but when it is deployed on another machine, a new problem occurs and the following content is introduced.

Ii. CDO. Configuration
When the system is deployed, the system prompts "sendusing error" when an email is sent. Exchange was not installed on my machine at the beginning, and the code written can run, but I don't know where the email is sent. On the machine where exchange is installed, exchange is sent from the local machine. I personally think, specifically, it is an exchange server in the same domain as the web server. So how does CDO. dll work?
Cdopostusing has these two enumerated values, see SDK. http://msdn2.microsoft.com/en-us/library/ms527265.aspx for details

Cdosendusingpickup

1

Send message using the local SMTP service pickup directory.

Cdosendusingport

2

Send the message using the Network (SMTP over the network ).

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.