0
        String[] Sendto = File.ReadAllLines("SendTo.txt");
        SmtpClient X = new SmtpClient("smtp.gmail.com", 587);
        //X.UseDefaultCredentials = false;

        NetworkCredential Auth = new NetworkCredential("Someone@gmail.com", "Plainttext password");
        X.Credentials = Auth;
        X.EnableSsl = true;
        foreach (string recip in Sendto)
        {
            try
            {
                MailAddress from = new MailAddress("Someone@gmail.com");

                MailAddress to = new MailAddress(recip);
                MailMessage myMail = new MailMessage(from, to);
                myMail.Priority = MailPriority.High;
                myMail.Subject = "Your Test is Done";
                myMail.SubjectEncoding =
                myMail.BodyEncoding = System.Text.Encoding.UTF8;
                myMail.IsBodyHtml = true;
               X.Send(myMail);
            }
            catch (Exception ex)
            { Console.WriteLine(ex.Message); }

なぜこれが機能しないのですか?トラフィックを盗聴しました。smpt.google.com から dns 応答を受け取りましたが、リモート サーバーへの接続に失敗しました

4

1 に答える 1

0

変更された回答ポート 993 が機能しませんでした...

私のために働いたのは:-

2 段階認証を使用している場合は、アプリ固有のパスワードが必要になる場合があることに注意してください。

var mail = new MailMessage();

mail.From = new MailAddress("from address");
mail.To.Add("to address");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";

var smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Port = 587;
smtpServer.Credentials = new System.Net.NetworkCredential("user", "password");
smtpServer.EnableSsl = true;
smtpServer.Send(mail);
于 2013-04-19T16:14:19.397 に答える