Home > Backend Development > C#.Net Tutorial > c# calls qq mailbox smtp to send mail modified version code

c# calls qq mailbox smtp to send mail modified version code

高洛峰
Release: 2017-05-24 14:19:37
Original
2416 people have browsed it

 try
            {
                MailMessage mm = new MailMessage();
                MailAddress Fromma = new MailAddress("xxxx@qq.com");
                MailAddress Toma = new MailAddress("MMMMMMM@qq.com", null);
                mm.From = Fromma;
                //收件人
                mm.To.Add("MMMMMM@qq.com");
                //邮箱标题
                mm.Subject = "Hello Dear:";
                mm.IsBodyHtml = true;
                //邮件内容
                mm.Body = "你好Mr流星!";
                //内容的编码格式
                mm.BodyEncoding = System.Text.Encoding.UTF8;
                //mm.ReplyTo = Toma;
                //mm.Sender =Fromma;
                //mm.IsBodyHtml = false;
                mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
                mm.CC.Add(Toma);
                SmtpClient sc = new SmtpClient();
                NetworkCredential nc = new NetworkCredential();
                nc.UserName = "XXXXX@qq.com";//你的邮箱地址
                nc.Password = "zzzzz";//你的邮箱密码,这里的密码是xxxxx@qq.com邮箱的密码,特别说明下~
                   sc.UseDefaultCredentials = true;
                sc.DeliveryMethod = SmtpDeliveryMethod.Network;
                sc.Credentials = nc;
                //如果这里报mail from address must be same as authorization user这个错误,是你的QQ邮箱没有开启SMTP,
                //到你自己的邮箱设置一下就可以啦!在帐户下面,如果是163邮箱的话,下面该成smtp.163.com
                sc.Host = "smtp.qq.com";
                sc.Send(mm);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
Copy after login

I tested this successfully with my 2 QQs. If there are any questions, I hope you can correct me~~

Please pay attention to more related articles about the modified code of c# calling qq mailbox smtp to send emails. PHP Chinese website!

【Related Recommendations】

1. Detailed introduction to Python’s example of using SMTP to send emails

2. Python Summary of code for sending emails using SMTP

3. Sharing graphic examples of sending emails using SMTP using Python

4. Sending emails using SMTP using Python

5. php smtp sends email

6. Detailed explanation of Python SMTP email module

7. Python smtplib module sends SSL/TLS secure email example

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template