Send emails directly through smtp, and send emails directly through smtp

Source: Internet
Author: User
Tags mailmessage smtpclient

Send emails directly through smtp, and send emails directly through smtp

/// <Param name = "fromEmail"> sender's email address </param>
/// <Param name = "toEmail"> multiple recipients are separated by commas (,). </param>
/// <Param name = "ccEmail"> multiple CC messages are separated by commas (,). </param>
/// <Param name = "bccEmail"> separate multiple BCC messages with commas (,). </param>
/// <Param name = "subject"> subject </param>
/// <Param name = "body"> email body </param>
/// <Param name = "smtpAddress"> email sending server </param>
/// <Param name = "account"> email sending account </param>
/// <Param name = "pwd"> email sending password </param>
/// <Returns> </returns>
Public static bool SendMailBySMTP (string body)
{
System. Net. Mail. MailMessage mail = new System. Net. Mail. MailMessage ("your mailbox @ yingu.com", "Your mailbox @ yingu.com ");

// Mail. s
Mail. SubjectEncoding = Encoding. UTF8;
Mail. Subject = "An error occurred while retrieving the matching data of Creditor's Rights Data ";
Mail. IsBodyHtml = true; // whether the content is allowed in HTML Format
Mail. BodyEncoding = Encoding. UTF8;
Mail. Body = body;
SmtpClient smtp = new SmtpClient ("smtp.qiye.163.com ");
Smtp. Credentials = new NetworkCredential ("your mailbox @ yingu.com", "email password"); // SMTP Verification
// Smtp. DeliveryMethod = SmtpDeliveryMethod. PickupDirectoryFromIis;
Bool rr = true;
Try
{
Smtp. Send (mail );
}
Catch (Exception ex)
{

Rr = false;
}
Mail. Attachments. Dispose (); // After the email is sent, the attachment is locked.
Return rr;
}

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.