zoukankan      html  css  js  c++  java
  • 如何使用gmail发送邮件

    using System.Web.Mail;


       // Mail initialization
    MailMessage mailMsg = new MailMessage();
    mailMsg.From = "test@test.com";
    mailMsg.To = "desti@126.com";
    //mailMsg.Cc = cc;
    //mailMsg.Bcc = bcc;
    mailMsg.Subject = "send mail use gmail";
    mailMsg.BodyFormat = MailFormat.Text;
    mailMsg.Body = "Hello here comes the sun";
    mailMsg.Priority = MailPriority.High;
    // Smtp configuration
    SmtpMail.SmtpServer = "smtp.gmail.com";
    // - smtp.gmail.com use smtp authentication
    mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
    mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "yourgmailaddress");
    mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "youpassword");
    // - smtp.gmail.com use port 465 or 587
    mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
    // - smtp.gmail.com use STARTTLS (some call this SSL)
    mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
    // try to send Mail
    try
    {
        SmtpMail.Send(mailMsg);
        Response.Write("send success");
    }
    catch (Exception ex)
    {
        Response.Write(ex.Message);
    }
  • 相关阅读:
    Fedora下使用minicom及USB串口线
    fedora装机后要运行的脚本(原创)
    终极 Shell
    深入学习 Git 工作流
    如何使用Git上传项目代码到github
    Fedora23 chrome 安装
    Fedora下安装deb包方法
    vim自动缩进设置
    Fedora 20 安装搜狗拼音输入法
    C语言stat()函数:获取文件状态
  • 原文地址:https://www.cnblogs.com/sunbingzibo/p/1094831.html
Copyright © 2011-2022 走看看