Vs. Net original code for sending a common email

Source: Internet
Author: User
Tags mailmessage smtpclient

Public static void Sendmail (string toemail, string bodyemail, string subjectemail)
{
Try
{
Mailmessage Mm = new mailmessage ();
Mm. From = new mailaddress ("MESSYSTEM@AMATECH.CN", "MES system ");
// Mailaddress mafrom = new mailaddress ("MESSYSTEM@AMATECH.CN", "MES system ");
// Mm. From = mafrom;
Mm. to. Add (toemail );
Mm. Body = bodyemail;
Mm. Subject = subjectemail;
Mm. Priority = mailpriority. High;
Smtpclient SC = new smtpclient ();
SC. Host = "172.22.236.5 ";
String userid = "";
String pswd = "";
String domain = "";
Userid = "Pega \ roy_gu ";
Pswd = "@ xiaoli123"
Domain = "mail.sz.honyun.cn"

SC. Credentials = new system. net. networkcredential (userid, pswd, domain );
SC. deliverymethod = smtpdeliverymethod. Network;
SC. Send (mm );
}
Catch
{
MessageBox. Show ("sending failed. \ r \ n please contact the administrator! "," MES system ", messageboxbuttons. OK, messageboxicon. Exclamation );
}
}

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.