わかった; メールメッセージを送信できないようです。これをコンソールアプリケーションとして実行しています:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace Email
{
class Program
{
static void EMail(string ToAddress, string Subject, string Body, string FromAddress, string Host, int Port, string Username, string Password)
{
System.Net.Mail.SmtpClient SMTPClient = new System.Net.Mail.SmtpClient(Host, Port);
System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage();
Message.To.Add(new System.Net.Mail.MailAddress(ToAddress));
Message.From = new System.Net.Mail.MailAddress(FromAddress);
Message.Body = Body;
Message.Subject = Subject;
SMTPClient.EnableSsl = true;
SMTPClient.Credentials = new System.Net.NetworkCredential(Username, Password);
SMTPClient.Send(Message);
SMTPClient.SendCompleted += new System.Net.Mail.SendCompletedEventHandler(FinishedSending);
}
static void FinishedSending(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
Console.WriteLine("DONE!");
}
static void Main(string[] args)
{
EMail("***********", "Hi!", "This is a test, Sent from a C# application.", "******", "smtp.gmail.com", 465, "****************", "**************");
Console.ReadLine();
}
}
}
エラーが発生していない、Gmail アカウントで受信していない、「DONE!」と書かれていない。ポート 465 の送信と受信を許可しました。ポート 465 で smtp.gmail.com を Telnet すると、空白のコマンド プロンプト ウィンドウが表示されます。ありがとう。