上記のエラーで、改ざんとクラッシュをclient.Send(email);
に保ちます。 4倍のすべてをチェックしました。ここでSystem.Net.Mail.SmtpException {"Failure Sending Email。"}
は私のコードです:
private void submit_Click(object sender, RoutedEventArgs e)
{
string from = "************@gmail.com";
string to = "*******@sru.edu";
string subject = "PSLM Test";
string body = "PSLM Test";
string server = "smtp.gmail.com";
int port = 465;
string username = "************";
string password = "*******";
SmtpClient client = new SmtpClient(server, port);
client.Credentials = new NetworkCredential(username, password);
MailMessage email = new MailMessage(from, to, subject, body);
email.Attachments.Add(new Attachment(GlobalVariables.attachedFilePath));
email.Attachments.Add(new Attachment(GlobalVariables.formsAndTemplatesPath[0]));
email.Attachments.Add(new Attachment(GlobalVariables.formsAndTemplatesPath[1]));
email.Attachments.Add(new Attachment(GlobalVariables.formsAndTemplatesPath[2]));
client.Send(email);
}
は私が間違って何をやっている、してください?
根本原因は何ですか?あなたがキャッチした例外の 'InnerException'プロパティをチェックしてください。 – lorond
_Always_ [InnerException'プロパティ](https://msdn.microsoft.com/en-us/library/windows/apps/system.exception.innerexception)を調べてください。 –
私はあなたのコードでエラーを指摘できるだけではないので、メールサーバーの設定と関係があります。あなたは、実際の問題に関してもっと詳細を含むかもしれない 'InnerException'をチェックしましたか? – Jamiec