Tag: gmail

Gmail:如何以编程方式发送电子邮件

可能完全重复: 通过Gmail在C#.NET中发送电子邮件 嗨, 我正在尝试使用gmail发送电子邮件: 我尝试了在本网站和其他网站上找到的各种示例,但我总是得到同样的错误: 无法连接到远程服务器 – > System.net.Sockets.SocketException:无法建立连接,因为目标主动拒绝它209.85.147.109:587 public static void Attempt1() { var client = new SmtpClient(“smtp.gmail.com”, 587) { Credentials = new NetworkCredential(“MyEmailAddress@gmail.com”, “MyPassWord”), EnableSsl = true }; client.Send(“MyEmailAddress@gmail.com”, “some.email@some.com”, “test”, “testbody”); } 有任何想法吗? UPDATE 更多细节。 也许我应该说我做出的其他尝试给了我同样的错误:(注意当我没有指定端口时它尝试端口25) public static void Attempt2() { var fromAddress = new MailAddress(“MyEmailAddy@gmail.com”, “From Name”); var toAddress = new […]

如何使用MailKit发送电子邮件?

根据新的谷歌政治https://googleonlinesecurity.blogspot.de/2014/04/new-security-measures-will-affect-older.html我无法发送电子邮件。 对于不使用OAuth 2.0的应用程序,谷歌会考虑“安全性较低的应用程序”。 我想使用MailKit来解决这个问题 var message = new MimeMessage(); message.From.Add(new MailboxAddress(“Joey Tribbiani”, “noreply@localhost.com”)); message.To.Add(new MailboxAddress(“Mrs. Chanandler Bong”, “mymail@gmail.com”)); message.Subject = “How you doin’?”; message.Body = new TextPart(“plain”){ Text = @”Hey” }; using (var client = new SmtpClient()) { client.Connect(“smtp.gmail.com”, 587); ////Note: only needed if the SMTP server requires authentication client.Authenticate(“mymail@gmail.com”, “mypassword”); client.Send(message); client.Disconnect(true); } 但是我An […]

使用Gmail的SmtpClient

我正在为学校项目开发一个邮件客户端。 我已经设法使用C#中的SmtpClient发送电子邮件。 这适用于任何服务器,但它不适用于Gmail。 我相信这是因为谷歌使用TLS。 我已经尝试在SmtpClient EnableSsl设置为true ,但这没有什么区别。 这是我用来创建SmtpClient并发送电子邮件的代码。 this.client = new SmtpClient(“smtp.gmail.com”, 587); this.client.EnableSsl = true; this.client.UseDefaultCredentials = false; this.client.Credentials = new NetworkCredential(“username”, “password”); try { // Create instance of message MailMessage message = new MailMessage(); // Add receiver message.To.Add(“myemail@mydomain.com”); // Set sender // In this case the same as the username message.From = new […]

在C#中阅读Gmail中的电子邮件

我正在尝试阅读Gmail中的电子邮件。 我已经尝试了我能找到的每个API /开源项目,并且不能让它们中的任何一个工作。 有没有人有一个工作代码示例,可以让我从Gmail帐户validation和下载电子邮件? 最终工作版本发布如下: https : //stackoverflow.com/a/19570553/550198

无法通过MailMessage和smtpClient身份validation到Gmail smtp

我无法弄清楚为什么这不起作用的生活 SmtpClient smtp = new SmtpClient { Host = “smtp.gmail.com”, Port = 587, UseDefaultCredentials = false, DeliveryMethod = SmtpDeliveryMethod.Network, Credentials = new NetworkCredential(“myemail@gmail.com”, “myGmailPasswordHere”), EnableSsl = true, Timeout = 10000 }; smtp.Send(mail); 我明白了: SMTP服务器需要安全连接或客户端未经过身份validation。 服务器响应为:5.5.1需要身份validation。 我刚刚将EnableSsl指定为true,因此在安全连接方面不应该是问题。 我是从localhost运行的。 是的,我输入auth(我的gmail帐户凭据)的用户名和密码是100%正确的。

如何通过Gmail发送带有C#的电子邮件

尝试通过我的Web服务发送电子邮件时收到错误。 我已尝试启用访问不太安全的应用程序,禁用两步validation并通过Web浏览器登录帐户。 SO的解决方案都没有对我有用。 我还在: 错误:System.Net.Mail.SmtpException:SMTP服务器需要安全连接或客户端未经过身份validation。 服务器响应为:5.5.1需要身份validation。 我该怎么做才能解决这个问题? namespace EmailService { public class Service1 : IService1 { public string SendEmail(string inputEmail, string subject, string body) { string returnString = “”; try { MailMessage email = new MailMessage(); SmtpClient smtp = new SmtpClient(); smtp.Host = “smtp.gmail.com”; // set up the Gmail server smtp.EnableSsl = true; smtp.Port = […]