2016-03-28 10 views
0

私は自分の電子メールの「返信パス」を設定しようとしていますが、使用可能なパラメータとして表示されません。それは回答者が同じものではないようです。私はバウンスされた電子メールが配信される場所を設定することを忘れました。これまでのところ私のコードです:C#smtpメールの返信パスを設定する方法

private static void SendMail(string html,string taxId,string toEmail,string filePath,string fromEmail,string replyToEmail,string emailSubject,string emailAttachPath) 
    { 
     try 
     { 
      MailMessage mail = new MailMessage();  
      mail.From = new MailAddress(fromEmail); 
      mail.To.Add(toEmail); 

      mail.Subject = emailSubject; 
      mail.Body = html; 

      //specify the priority of the mail message 
      mail.ReplyToList.Add(replyToEmail); 

      SmtpClient SmtpServer = new SmtpClient("smtp.server.com"); 
      SmtpServer.Port = 25; 
      SmtpServer.UseDefaultCredentials = true; 
      SmtpServer.EnableSsl = false; 
      mail.IsBodyHtml = true; 

      SmtpServer.Send(mail); 

     } 
     catch (Exception ex) 
     { 
      Console.WriteLine(ex.ToString()); 
     } 
    } 
+3

[この質問](http://stackoverflow.com/questions/8912861/sending-email-with-return -path-not-functioning)が役に立ちます。 –

+0

送信者属性を提案通りに設定しましたが、送信者の電子メールアドレスにバウンスされた電子メールメッセージはまだ届きません。 ITチームは、私には「リターンパス」が設定されていないためだと言います。 – mjanach

+0

件名の[別の質問です](http://stackoverflow.com/questions/4367358/whats-the-difference-between-sender-from-and-return-path)答えは以前のコメントとほとんど同意します。どのSMTPサーバーを使用していますか?サーバの設定に問題がある可能性はありますか? Outlookでこのサーバー経由でメッセージを送信できますか? Outlook(または別の電子メールクライアント)を使用しているときに、バウンスされたメッセージが返されますか? –

答えて

0

返信パスemailaddressを書いていないとします。サーバーはメールアドレスからリターンパスに変換されます。また、電子メールの元のソースで電子メールのレポートを見ることができます。カスタムreutnパスを追加したい場合は、使用することができます

enter image description here

MailMessage message = new MailMessage(); 
message.Headers.Add("Return-Path", "[email protected]*****.biz"); 
関連する問題