/*
Tofu is made of excellent products.
Http://www.asp888.net bean curd technology station
If reprinted, indicate the source
*/
Asp + complete Email sending manual. This article contains all common examples of Mail sending. Of course, we only
For example, if you have any comments, welcome to the http://www.asp888.net/bbs to discuss
1. Use asp + to send Simple Mail
<% @ Page Language = "C #" %>
<% @ Import Namespace = "System. Web. Util" %>
<%
String strTo = "asp888@asp888.net ";
String strFrom = "webmaster@asp888.net ";
String strSubject = "simple example of asp mail sending ";
SmtpMail. Send (strFrom, strTo, strSubject, "This is just a simple text mail ");
Response. Write ("Email has been sent successfully ");
%>
2. asp + send HTML-format mail
Please note that another sending command is used here
<% @ Page Language = "C #" %>
<% @ Import Namespace = "System. Web. Util" %>
<%
MailMessage msgMail = new MailMessage ();
MsgMail. To = "asp888@asp888.net ";
MsgMail. Cc = "doufu@asp888.net ";
MsgMail. From = "webmaster@asp888.net ";
MsgMail. Subject = "asp + send HTML-format mail ";
MsgMail. BodyFormat = MailFormat. Html;
String strBody = ""<Font color =" red "> ASP + </font> </body> MsgMail. Body = strBody;
SmtpMail. Send (msgMail );
Response. Write ("Email has been sent successfully ");
%>
3. asp + sends emails with attachments
<% @ Page Language = "C #" %>
<% @ Import Namespace = "System. Web. Util" %>
<%
MailMessage msgMail = new MailMessage ();
MsgMail. To = "asp888@asp888.net ";
MsgMail. From = "webmaster@asp888.net ";
MsgMail. Subject = "Attachment Test ";
MsgMail. BodyFormat = MailFormat. Text;
MsgMail. Body = "Check out the attachment! ";
MsgMail. Attachments. Add (new MailAttachment ("c: \ temp \ doufu.txt "));
SmtpMail. Send (msgMail );
Response. Write ("Email has been sent successfully ");
%>
Okay. After reading this article, do you have no problem with the operation of Email sending in asp +? Oh! And
It doesn't matter. Keep an eye on the updates on this site.