发送给收件人,同时在发件人列表中列出其他人 [英] Send to a recipient, while listing others in the sent-to list

查看:134
本文介绍了发送给收件人,同时在发件人列表中列出其他人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向一个人发送电子邮件,但发送给列表显示多个人。 (我不希望其他人收到电子邮件)。

I'd like to send an email to a single person, yet have the "sent to" list display a number of people. (I don't want those other people to receive the email).

许多文章(此处在此)建议为smtp地址和mime地址指定不同的值是完全合法的。

A number of articles (here and here) suggest it's perfectly legal to specify different values for smtp address and mime addresses.

我正在使用MailKit,这就是事实我到目前为止:

I'm using MailKit and this is what I have so far:

var message = new MimeMessage();
message.From.Add(new MailboxAddress("MeetingOfficeA", "noreply@office.com"));
message.To.Add(new MailboxAddress("Fidel Perez-Smith", "fidel@office.com"));

message.Headers.Add("To", "john.doe@office.com"); //this line actually sends the email to John Doe, which I don't want

message.Subject = "Testing";
message.Body = new TextPart ("plain") { Text = @"Testing 123" };

MailKit.Net.Smtp.SmtpClient client = new MailKit.Net.Smtp.SmtpClient();
client.Connect("smtpserver.office.com");
client.Send(message);

我是否可以添加一些内容,因此只有Fidel可以接收该电子邮件,但看起来已发送至

Is there something I can add so only Fidel receives the email, yet it looks like it was sent to multiple people?

(链接1中的问题类似,但主要讨论发件人地址。我认为我的问题不应标记为重复,因为它与到地址,将使其他用户更容易找到它。毕竟,当我研究特定问题时,花了一段时间才找到另一个链接)。

(The question in link 1 is similar, but mainly discusses the 'from' addresses. I think my question should not be marked as duplicate because it relates to the 'to addresses' and will make it easier for other users to find. After all, it took a while to find that other link when I was researching my particular issue).

推荐答案

下面的代码片段将使该消息既发送给Fidel Perez-Smith,又发送给John Doe,看起来像,但实际上,它只是发送给Fidel Perez-Smith:

The following code snippet will make it look like the message was sent to both Fidel Perez-Smith and John Doe, but in reality, it will only be sent to Fidel Perez-Smith:

var message = new MimeMessage ();
message.From.Add (new MailboxAddress ("MeetingOfficeA", "noreply@office.com"));
message.To.Add (new MailboxAddress ("Fidel Perez-Smith", "fidel@office.com"));
message.To.Add (new MailboxAddress ("John Doe", "john.doe@office.com");
message.Subject = "Testing";
message.Body = new TextPart ("plain") { Text = @"Testing 123" };

using (var client = new SmtpClient ()) {
    client.Connect ("smtpserver.office.com");
    client.Send (message, new MailboxAddress ("MeetingOfficeA", "noreply@office.com"), new [] { new MailboxAddress ("Fidel Perez-Smith", "fidel@office.com") });
    client.Disconnect (true);
}

这篇关于发送给收件人,同时在发件人列表中列出其他人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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