网站建设资讯

NEWS

网站建设资讯

c#winform程序用126邮箱发邮件-创新互联

代码如下:c#winform程序用126邮
箱发邮件
   private void button1_Click(object sender, EventArgs e)
        {
string strTitle = "alert! We have not receive new data from mera over 20 mins";

try
            {
                SmtpClient client= new SmtpClient("smtp.126.com", 25)
                {
                    Credentials= new NetworkCredential("emailAddress", "password"),
                    EnableSsl= true
                };

                MailAddressfrom = new MailAddress(@"emailAddress", "senderName");
                MailAddress to= new MailAddress(@"receiverAddress", "ReceiverName");
                MailMessage myMail= new System.Net.Mail.MailMessage(from, to);

                myMail.Subject= strTitle;
                myMail.SubjectEncoding= System.Text.Encoding.UTF8;
                myMail.Body= "";

                myMail.BodyEncoding= System.Text.Encoding.UTF8;
                client.Send(myMail);

            }
catch (SmtpException ex)
            {
throw new ApplicationException
                  ("SmtpException has occured:" + ex.Message);
            }
        }// end of function

需要注意的是, 要使用注册很久的126邮箱发送,因为新注册的邮箱网易限制了这个功能 。

站在用户的角度思考问题,与客户深入沟通,找到广信网站设计与广信网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站制作、成都网站建设、企业官网、英文网站、手机端网站、网站推广、域名注册网站空间、企业邮箱。业务覆盖广信地区。
新闻名称:c#winform程序用126邮箱发邮件-创新互联
网址分享:http://njwzjz.com/article/dppdio.html