. Net email sending implementation

Source: Internet
Author: User
Tags mailmessage

// Create a mailmessage object

Mailmessage mailmsg = new mailmessage ();

// Set the recipient's email address

Mailmsg. To = txw.text;

// Set the sender's email address

Mailmsg. From = txtfrom. text;

// Set the Email Subject

Mailmsg. Subject = txtsubject. text;

// Set the email content

Mailmsg. Body = txtmsg. text;

// Supports Server verification.

Mailmsg. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1 ");

// Set the user name

Mailmsg. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", "songxiuduo_999@163.com ");

// Set the User Password

Mailmsg. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendpassword", "sxd999 ");

// Try


// Set the email sending server

Smtpmail. smtpserver = "smtp.163.com ";

// Send an email

Smtpmail. Send (mailmsg );

Lblmsg. Text = "sent successfully ";


// Catch


// Lblmsg. Text = "failed to send ";


Note the following when running this example:

1. If your machine is equipped with anti-virus software such as rising, disable the "mail sending monitoring and mail acceptance monitoring" function.

2. Set the email server correctly.

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.