在ASP.NET程序员 用GMail信任票据发送邮件

地址如下:

http://www.codeproject.com/KB/aspnet/aspnetemailusinggmail.aspx

public static void sendMail(string to, string from, string subject,
              string body,string username, string password)
{
    ///Smtp config
    SmtpClient client = new SmtpClient("smtp.gmail.com", 465);
    // Edit password and username
    client.Credentials = new NetworkCredential(""+username+"@gmail.com", password);
    client.EnableSsl = true;

    Mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] =
                ""+username+"@gmail.com";
    Mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = password;

client.Credentials = new NetworkCredential("USERNAME@gmil.com", "PASSWORD");
Mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] =
            "USERNAME@gmail.com";
Mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "PASSWORD";

 

作者来自 斯里兰卡(南亚岛国)。

原文地址:https://www.cnblogs.com/JamesLi2015/p/1331077.html