c# - remove recipient from mail.recipient collection -
i have application sends e-mail via outlook. code receives mail recipient list program. issue need remove 1 of e-mail addresses before sending e-mail.
this receive, recipients populated.
outlook.mailitem mail = _otapp.createitem(outlook.olitemtype.olmailitem);
i know can add new recipients using line below,
mail.recipients.add("joe.blogs@someaddress.com");
i know there mail.recipients.remove method. method though requires me know position of e-mail address need remove not know.
you can use recipient.delete. following (off top of head):
foreach (var recipient in mail.recipients) { if (string.compare(recipient.address, "joe.blogs@someaddress.com", true) == 0) { recipient.delete(); break; } }
Comments
Post a Comment