Complete asp + Email sending Manual

Source: Internet
Author: User

/*
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.


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.