【发布时间】:2018-08-23 18:19:02
【问题描述】:
我编写了一个程序,当单击按钮时应该会收到收件人电子邮件。当我使用 mailItem.Save() 时它可以工作,但这会复制收件人并将其保存到我不想发生的草稿文件夹中。
有什么方法可以调用“检查名称”的功能吗?或者我应该怎么做才能让所有收件人而不是使用 mailItem.Save() ?
流程:
- 在“收件人”字段中输入收件人电子邮件地址
- 点击按钮获取收件人电子邮件。
片段:
//CC account manager when this button is clicked
private void uxCcManager_Click(object sender, RibbonControlEventArgs e)
{
//check if user is authorized to use this feature
if (!CheckAuthorization())
{
return; // Authentication failed do not proceed any further
}
//save mail items entered in fields else they will get overidden by space
mailItem.Save();
mailItem.Recipients.ResolveAll();//check recepent name
if (mailItem != null)
{
//check if EntryID (unique id passed as a parameter of the event) of the currentItem not null.
//the entry id changes when an item is moved from folder to folder(drafts->outbox->Sent Items).
if (mailItem.EntryID != null)
{
if (mailItem.To == null)
{
MessageBox.Show("Please, enter the email address that you're sending email to!");
}
else if (mailItem.To != null)
{
//get individual emails from mailItem.To for the purpose of getting indivdual account manager
if (!IndividualRecipent(mailItem.Recipients))
{
MessageBox.Show("Cannot identify one or more emails, please check names and try again.");
}
}
}
}
}
【问题讨论】: