Use System.Web.Mail to send mail through a mail server that needs to be validated

Source: Internet
Author: User
Tags mailmessage
Use System.Web.Mail to send mail through a mail server that needs to be validated

Using System.Web.Mail to send mail through a mail server that needs to be validated, the following is a mail-sending class written by Scott Water in Dottext, which is easy to use, with the entire class code as follows:
Using System;
Using System.Web.Mail;

Namespace ZZ
{
///
Summary description of the systemmail.
///
public class Systemmail
{
private string _adminemail;
private string _smtpserver = "localhost";
private string _password;
private string _username;

Public Systemmail ()
{
}


public string AdminEmail
{
Get{return _adminemail;}
Set{_adminemail = value;}
}


public string SmtpServer
{
Get{return _smtpserver;}
Set{_smtpserver = value;}
}


public string Password
{
Get{return _password;}
Set{_password = value;}
}


public string UserName
{
Get{return _username;}
Set{_username = value;}
}

public bool Send (string to, string from, string subject, String message)
{
Try
{
MailMessage em = new MailMessage ();
Em. to = to;
Em. from = from;

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.