there are many demos for send a email with c sharp language .however,you will find that most of them will be failed because of SMTPServer.Especially,authorization is required.
publicvoidSendEMail()
...{
MailMessagemail=newMailMessage();
mail.Priority=MailPriority.High;
mail.From="cccc@gmail.com";
mail.To="cccc@163.com";
mail.Subject="SendEMailSystemDemo";
mail.Body="Justfortest.";
mail.BodyEncoding=Encoding.UTF8;
//authorization
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing",1);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendemailaddress",mail.From);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress",mail.From);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname","cccc@163.com");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","cccc");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver","smtp.163.com");
SmtpMail.SmtpServer="smtp.163.com";
SmtpMail.Send(mail);
}
#endregion
本文提供了一个使用C#语言发送邮件的示例代码。该示例详细展示了如何配置SMTP服务器及验证信息来确保邮件成功发送。对于需要通过163邮箱发送邮件的开发者来说,这是一个很好的起点。
676

被折叠的 条评论
为什么被折叠?



