Asp.net can implement identity authentication email sending method (C)

Source: Internet
Author: User
Tags mailmessage
Public Void Sendmail ()
{
// Instantiate a mailmessage object
System. Web. Mail. mailmessage mail = New System. Web. Mail. mailmessage ();

// Define the mail sending Address
Mail. From = " Aierong@126.com " ;

// Define the email Receiving address
// Set a list of recipient email addresses separated by semicolons
Mail. = " Aierong@126.com " ;

// Defines the mail's dark sending Address
// Set the list of email addresses separated by semicolons
Mail. bcc = " A@126.com " ;

// Define the CC address of an email
// Set the list of email addresses separated by semicolons
Mail. CC = " Abc@371.net aaa@263.net " ;

// Define the subject of an email
Mail. Subject = " . Net email " ;

// Set the email body content type
// Here, we send messages in HTML Format
Mail. bodyformat = System. Web. Mail. mailformat. html;

// Set email body
Mail. Body = " Go go " ;

// Set an attachment
System. Web. Mail. mailattachment = New System. Web. Mail. mailattachment ( @" D: \ abc.doc " );

// Attach an attachment to the email
Mail. attachments. Add (mailattachment );

// SMTP Server
// Authentication is required for many SMTP servers.
System. Web. Mail. smtpmail. smtpserver = " Smtp.126.com " ;

// Verify
Mail. Fields. Add ( " Http://schemas.microsoft.com/cdo/configuration/smtpauthenticate " , " 1 " );
// Login Name
Mail. Fields. Add ( " Http://schemas.microsoft.com/cdo/configuration/sendusername " , " Aierong " );
// Login Password
Mail. Fields. Add ( " Http://schemas.microsoft.com/cdo/configuration/sendpassword " , " ******* " );

// Send
System. Web. Mail. smtpmail. Send (Mail );
}

This method can send an email to the Internet

ReferenceArticleYou can see
Http://www.systemwebmail.com/faq/3.8.aspx

Related Article

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.