You want to use QQ mail to send mail to configure the mail server for the QQ mailbox mail server mail.qq.com.
Then fromaddress there to configure your email address,
Objsmtpclient.credentials need your email and password.
Method SendMail (String mailaddress, String mailtitle, String mailcontent)
Need parameters mailaddress for the email address you want to send, mailtitle for the message subject, mailcontent for the message content.
Reference is also required: using System.Net.Mail;
public static void SendMail (String mailaddress, String mailtitle, String mailcontent)
{
MailMessage objmailmessage = new MailMessage ();
String fromaddress = configurationmanager.appsettings["fromaddress"];//the sender address that you configured in Web. config is your e-mail address.
String mailHost = configurationmanager.appsettings["MailHost"];//mail server, such as mail.qq.com
Objmailmessage.from = new MailAddress (fromaddress);//Sender Address
OBJMAILMESSAGE.TO.ADD (New MailAddress (mailaddress));//Addressee Address
objmailmessage.bodyencoding = system.text.encoding.utf8;//message encoding
Objmailmessage.subject = mailtitle;//message Header
Objmailmessage.body = mailcontent;//message content
objmailmessage.isbodyhtml = true;//Whether the message body is in HTML format
SmtpClient objsmtpclient = new SmtpClient ();
Objsmtpclient.host = mailhost;//mail server address
Objsmtpclient.deliverymethod = smtpdeliverymethod.network;//sent over the network to the STMP mail server
Objsmtpclient.credentials = new System.Net.NetworkCredential ();//sender's email address, password
OBJSMTPCLIENT.ENABLESSL = TRUE;//SMTP server requires a secure connection to set this property
Try
{
Objsmtpclient.send (Objmailmessage);
}
catch (Exception ex)
{
Loghelper.writelog (Logfile.error, ex. ToString ());//Record error log
}
}
C#_ sending mail