zoukankan      html  css  js  c++  java
  • using System.Web.Mail to send email

    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.

    public void SendEMail()
            
    {
                MailMessage mail 
    = new MailMessage();
                mail.Priority 
    = MailPriority.High;
                mail.From 
    = "cccc@gmail.com";
                mail.To 
    = "cccc@163.com";
                mail.Subject 
    = "Send EMail System Demo";
                mail.Body 
    = "Just for test.";
                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
  • 相关阅读:
    qs.parse()、qs.stringify() 、JSON.stringify()以及JSON.parse()的区别
    Vue设置button的disable属性
    vue-preview用法详解
    解决MUI不支持js严格模式环境下使用的问题
    Vue.js的keep-alive用法
    详解在webpack中使用axios
    详解VS2012发布web api流程
    解决Python2中文ascii编码的方法
    防火墙问题 Linux系统 /etc/sysconfig/路径下无iptables文件
    本机连接虚拟机中docker启动的mysql数据库
  • 原文地址:https://www.cnblogs.com/AloneSword/p/2237542.html
Copyright © 2011-2022 走看看