私のプログラムには、Googleアカウントから電子メールを送信する機能があります。電子メールを送信する際にエラーが発生しましたsystem.web.httpexceptions:メッセージをsmtpサーバーに送信できませんでした
私はこのコードを書いていましたが、それはうまく動作していました。しかし今、私はそれを働かせることができませんでした。 (私は現在、Windows 7 64-bitで作業していますが、それが違いを生むならば)。
(コードから最初のエラーメッセージである)私が手にエラーがある:
system.web.httpexceptions:メッセージは、SMTP サーバに送信することができませんでした。トランスポートエラーコードは0x80040217でした。サーバーの応答 は利用できませんでした - > system.reflection.targetinvocationexception: 呼び出しのターゲットによって例外がスローされました。 - > system.runtime.interopservice.comexception(0x80040211): メッセージをsmtpサーバーに送信できませんでした。トランスポートエラーコードは 0x80040217でした。サーバーの応答は利用できませんでした。
これはコードです:
void sendEmail(string [] emailList, int emailLength, string fileName)
{
int i = 0; //variable to act as temporary index into emailList array
try
{
try
{
MailMessage message = new MailMessage();
//Because using google server, requires SSL
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","[email protected]");
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","thepassword");
message.From = "[email protected]";
message.To = emailList[i];
//add Bcc
while (++i < emailLength)
{
message.Bcc = emailList[i];
}//end while
message.Subject = "Test Subject";
message.Body = "Test Body";
MailAttachment fileAttach = new MailAttachment(fileName);
message.Attachments.Add(fileAttach);
try
{
SmtpMail.SmtpServer = "smtp.gmail.com";
は、事前にありがとうございます!
0x80040217は、サーバがリクエストを拒否意味自分のアカウントへのアクセスをブロックしています。デバッグステップについては、これを確認してください:http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/2bdde9e6-b57a-4b12-b476-7bcf1f8f66d5/ – devshorts
はい、あなたが私に与えたリンクは、thanx devshorts –
解決策を投稿したら、 – devshorts