选择用于发送电子邮件的域帐户 [英] choosing which domain account to use for sending email

查看:117
本文介绍了选择用于发送电子邮件的域帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用于向客户端发送电子邮件的代码。

I have code for sending email to clients.

System.Net.Mail.SmtpClient Client = new System.Net.Mail.SmtpClient();
MailMessage Message = new MailMessage("From", "To", "Subject", "Body");
Client.Send(Message);

在App.config中具有以下内容。

With following in App.config.

 <system.net>
    <mailSettings>
      <smtp from="support@MyDomain1.com">
        <network host="smtp.MyDomain1.com" port="111" userName="abc" password="helloPassword1" />
      </smtp>
    </mailSettings>
    <mailSettings>
      <smtp from="support@MyDomain2.com">
        <network host="smtp.MyDomain2.com" port="222" userName="xyz" password="helloPassword2" />
      </smtp>
    </mailSettings>
  </system.net>

问题是在我的代码中如何区分给定邮件使用哪种邮件设置,即何时我想从MyDomain1帐户与MyDomain2帐户发送邮件

Problem is that in my code how can I differentiate which mailsetting to use for a given mail, meaning when I want to send mail from MyDomain1 account vs MyDomain2 account

推荐答案

有一个线程包含如何实现此目的的说明。

There's one thread that contains the explanation how to achieve this.

设置多个SMTP

最初是想将其发布为答案,但系统会自动将其转换为注释。似乎我必须写更长的消息。

Wanted originally to post it as an answer, but the system automatically converted it into a comment. Seems I have to write longer messages.

很高兴:)

这篇关于选择用于发送电子邮件的域帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆