• WebMail发送邮件


    MVC提供了WebMail来帮助我们发送邮件,很简单

    @{
                    WebMail.SmtpServer = "smtp.163.com";          
                    WebMail.SmtpPort = 25;           
                    WebMail.EnableSsl = false;        
                    WebMail.UserName = "username";     
                    WebMail.Password = "password";       
                    WebMail.From = "username@163.com";
                    WebMail.Send("565791254@qq.com","RSVP Notification","廖伟,你快回来");
    }

    发送附件

    var fileAttachment = Request["fileAttachment"];
    WebMail.SmtpServer = "smtp.163.com";
    WebMail.SmtpPort = 25;
    WebMail.EnableSsl = true;
    WebMail.UserName = "username";
    WebMail.Password = "password";
    WebMail.From = username@163.com;
    var filesList = new string[] { fileAttachment };
    //多个收件人之间用”,“分隔
    WebMail.Send(to: "
    3747353312@qq.com,7637044535@qq.com", subject: "TestWebMail", body: "这是test邮件", filesToAttach: filesList);

    如果遇到如下问题,检查UserName或者Password是否正确

    Tag:多个收件人之间用”,“分隔,在msdn上说的是用”;“分隔,而我用”;“出现

  • 相关阅读:
    迭代器&可迭代对象
    递归&栈帧空间
    locals()和globals()
    闭包
    nonlocal和global
    LEGB
    python中编码问题
    关于dict的formkeys方法注意
    深浅拷贝
    通过远程连接批量查看zookeeper服务状态和判断主从节点
  • 原文地址:https://www.cnblogs.com/DonnyPeng/p/3090762.html
Copyright © 2020-2023  润新知