以下のコードを使用してGmailを使用してメールを送信しようとしていますが、「リモートホストに接続できません」というエラーが表示され続けます。私は設定をダブルチェックして、すべてがうまく見えます。誰かが私が行方不明のものを参照してください?SmtpClient send mail
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("[email protected]", "mypass");
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
MailMessage mail = new MailMessage();
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "subject thing";
mail.Body = "dubbly doo";
try
{
client.Send(mail);
}
catch(SmtpException e)
{
Console.Write(e.InnerException.Message);
Console.ReadLine();
}
}
}
}
どの行にエラーが発生しますか? –
可能な複製:http://stackoverflow.com/questions/32260/sending-email-in-net-through-gmail –
@KendallFrey client.Send(メール)はエラーが発生する場所です – steventnorris