• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++ Programmer's Cookbook

            {C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

            Sending Email in .NET

            Author: James Foster Date Posted: 09/05/2001 .NET Version: 1.0.3705
            If you've had to send email with regular ASP, you've probably used CDONTS. In .NET, this functionality has been rolled into the Framework, and is part of the System.Web.Mail namespace. Using the classes in this namespace, you can easily construct and send email, with attachments if you wish, using the SMTP service built into Windows.
            System.Web.Mail Namespace
            The System.Web.Mail namespace is composed of three classes and three enumerations.

            Classes:

            MailAttachmentRepresents the attachments of an email.
            MailMessageRepresents the email itself.
            SmtpMailResponsible for sending MailMessages via SMTP.

            Enumerations:

            MailEncodingSpecifies the Encoding of the message: Base64 or UUEncode
            MailFormatSpecifies the Format of the message: Html or Text
            MailPrioritySpecifies the Priority of the message: High, Medium, or Low.
            Constructing the MailMessage
            The MailMessage object represents an email. You start by instantiating a MailMessage object, and then set the properties with the details of the email. The following properties are the ones you are most likely to use in your application:

            Attachmentsthe list of attachments (represented by MailAttachment objects) that are transmitted with the email
            Bcca semicolon-delimited list of email addresses that receive a Blind Carbon Copy (BCC) copy of the email message
            Bodythe body of the email
            BodyFormatspecifies the MailFormat of the email
            Cca semicolon-delimited list of email addresses that receive a Carbon Copy (CC) of the email message
            Fromthe email address of the sender
            Priorityspecifies the MailPriority of the email
            Subjectthe subject of the email
            Tothe email address of the recipient
            UrlContentBasethe URL base of all relative URL's used in an Html Body
            UrlContentLocationSpecifies the Priority of the message: High, Medium, or Low.
            Sending with SmtpMail
            Once you have constructed your MailMessage object, you use another object, SmtpMail, to actually send it. The most important method on the SmtpMail object is a static method, Send. This method has two variants. One allows you to send a MailMessage object:
            SmtpMail.Send(myEmailObject);
            Another variant allows you to specify the sender, recipient, subject and the body of an email, and have it sent right away.
            SmtpMail.Send(strFrom, strTo, strSubject, strBody);
            Example
            Now let's look at an example that pulls this all together. We'll start by creating a MailMessage object, setting a few properties, and finally sending the email with the SmtpMail object.

            <%@ Page Language="C#"%>

            <scriptlanguage="C#"runat="server">

            void Page_Load()
            {
            ????// CREATE A MAIL MESSAGE
            ????System.Web.Mail.MailMessage myEmail=new System.Web.Mail.MailMessage();

            ????// SET MESSAGE PARAMETERS
            ????myEmail.From ="agent@mypersonalshoppers.com";
            ????myEmail.To ="john@johnsmith.com";
            ????myEmail.Subject ="Product Availability Notice";
            ????myEmail.BodyFormat = System.Web.Mail.MailFormat.Html;
            ????myEmail.Body ="The sunglasses you expressed interest in are now in stock.";

            ????//SEND THE MESSAGE
            ????System.Web.Mail.SmtpMail.Send(myEmail);

            ????//UPDATE STATUS
            ????lblMailStatus.Text ="Mail successfully sent.";
            }

            </script>

            <html>
            <body>

            <asp:Label id="lblMailStatus"runat="server"/>

            </body>
            </html>

            posted on 2006-04-14 12:43 夢在天涯 閱讀(443) 評論(0)  編輯 收藏 引用 所屬分類: C#/.NET

            公告

            EMail:itech001#126.com

            導航

            統(tǒng)計

            • 隨筆 - 461
            • 文章 - 4
            • 評論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1807602
            • 排名 - 5

            最新評論

            閱讀排行榜

            国产福利电影一区二区三区久久老子无码午夜伦不 | 久久被窝电影亚洲爽爽爽| 日日噜噜夜夜狠狠久久丁香五月| 久久99精品国产麻豆宅宅| 国产精品一久久香蕉国产线看观看| 99久久精品免费| 亚洲精品美女久久久久99| 26uuu久久五月天| 久久九九久精品国产免费直播| 999久久久免费精品国产| 久久久国产精品| 国产精品一久久香蕉产线看 | 中文字幕久久精品 | 奇米影视7777久久精品| 国产精品久久久久久搜索| 思思久久好好热精品国产| 久久亚洲综合色一区二区三区| 久久人人爽人人人人片av| 久久久不卡国产精品一区二区| 99久久婷婷国产综合亚洲| 久久久久亚洲av综合波多野结衣| 免费观看久久精彩视频| 久久久久久久久无码精品亚洲日韩| 久久人妻少妇嫩草AV无码蜜桃| 久久精品视频网| 久久99精品久久只有精品| 99精品国产综合久久久久五月天 | 久久久久久亚洲AV无码专区| 日韩欧美亚洲综合久久| 青青草原综合久久大伊人导航| 一本久久a久久精品综合夜夜| 久久99国产精品久久99果冻传媒| 狠狠色婷婷久久一区二区| 伊人久久大香线蕉精品不卡| 欧美激情精品久久久久久| www亚洲欲色成人久久精品| 久久精品国产亚洲欧美| 伊人久久大香线焦综合四虎| 狠狠色综合久久久久尤物| 99久久国产综合精品网成人影院 | 老色鬼久久亚洲AV综合|