我想用C#和我有麻烦这样做(4 System.Net.Mail /框架)通过谷歌应用程序/ Gmail发送一个基本的电子邮件。通过谷歌应用程序发送电子邮件在C#
我收到以下异常:“操作超时”。
我的代码如下:
//Create the mail message
MailMessage mail = new MailMessage();
//Set the addresses
mail.From = new MailAddress("[email protected]", "My Name");
mail.To.Add(Email);
//Set the subject and bodycontent
mail.Subject = "Email Testing";
mail.Body = "This is the body of the email";
//Send the message using the SmtpClient
SmtpClient smtp = new SmtpClient();
smtp.EnableSsl = true;
smtp.Send(mail);
我的web.config具有以下设置:
<smtp from="[email protected]" deliveryMethod="Network">
<network host="smtp.gmail.com"
userName="[email protected]"
password="password"
port="587" />
</smtp>
在我的疑难解答我曾尝试:
- 用我个人的Gmail地址以及来自通过Google Apps托管的域中的另一个域名。
- 使用端口25,465,和587
- 硬编码在C#代码的配置设置,而不是使用在web.config
- 发送和telnet命令直接登录从多个网络位置,以确保在防火墙/ ISP不阻止它
- 确保在GMail设置中启用了POP(根据谷歌,这应该打开使用SMTP发送的能力)
- 更改发送和回复地址以确保它们与帐户匹配(显然是GMail必需)。
我可以通过GMail界面为我的两个电子邮件帐户发送和接收电子邮件。我也尝试了问题#757987中提供的设置和解决方案无济于事。
有没有人有这与最近的GMail工作?我认为Google最近改变了一些安全设置,这导致了我的症状。 – NateReid 2010-04-09 03:19:10