开发者

specifying "To" address in SMTP mail settings in .NET

Is it possible to set "To" address in SMTP mail settings just like "From" address? there is an attribute for "From", but开发者_StackOverflow社区 not "To" address. basically I need to send an email to technical support whenever a specific exception (or any unhandled exception) happens in the application. I can add it to "appSettings", but wondering if I can specify it in SMTP settings itself, without having to read from "appSettings". thanks in advance

  <system.net>
    <mailSettings>
      <smtp deliveryMethod="network" from="ben@contoso.com">
        <network host="some server" defaultCredentials="true" />
      </smtp>
    </mailSettings>
  </system.net>


No, you cannot specify the To property in the config file. You will need to set it programatically.


Well, you'll have to set the TO, CC, BCC, Subject, Content and a few other fields when you're calling the SendMail() function from your code.

It wouldn't make sense to define one single TO address as the only thing it would ever do is send mail from ben@contoso.com to jill@contoso.com.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜