从mail.recipient集合中删除收件人 [英] remove recipient from mail.recipient collection

查看:137
本文介绍了从mail.recipient集合中删除收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过Outlook发送电子邮件的应用程序.我的代码从另一个程序接收邮件收件人列表.问题是,在发送电子邮件之前,我需要删除其中一个电子邮件地址.

I have an application that sends an e-mail via outlook. My code receives a mail recipient list from an another program. The issue is that I need to remove one of the e-mail addresses before sending the e-mail.

这是我收到的,已经装有收件人.

This is what I receive, with recipients already populated.

  Outlook.MailItem mail = _otApp.CreateItem(Outlook.OlItemType.olMailItem);

我知道我可以使用下面的行添加新的收件人,

I know I can add new recipients using the line below,

  mail.Recipients.Add("joe.blogs@someaddress.com");

我也知道有一个mail.Recipients.Remove方法.但是,此方法要求我知道我需要删除的电子邮件地址的位置,我不知道该位置.

I also know there is a mail.Recipients.Remove method. This method though requires me to know the position of the e-mail address I need to remove which I do not know.

推荐答案

您可以使用Recipient.Delete.类似于以下内容(不在我的头上):

You can use Recipient.Delete. Something like the following (off the top of my head):

foreach (var recipient in mail.Recipients)
{
   if (string.Compare(recipient.Address, "joe.blogs@someaddress.com", true) == 0)
    {
        recipient.Delete();
        break;
    }
}

这篇关于从mail.recipient集合中删除收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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