[英]OUTLOOK VSTO: delete an email after sending it
I'm working with vsto for outlook. 我正在与vsto合作寻求前景。 Create an email message and send it to recipient.
创建电子邮件并将其发送给收件人。
I want to delete the e-mail from "sent items" (or prevent its entrance there) but can not find a way to do it. 我想从“已发送邮件”中删除电子邮件(或阻止其进入该地址),但找不到解决方法。
During my attempts I tried to filter emails in "sent items" by "find" and "restrict" functions on the "recipient" but I got an error of "Condition is not valid" or "Cannot parse condition. Error at "...."". 在尝试过程中,我尝试通过“收件人”上的“查找”和“限制”功能过滤“已发送邮件”中的电子邮件,但出现“条件无效”或“无法解析条件。错误为”的错误。 ..“”。
My Code is: 我的代码是:
MailItem reportEmail = Globals.ThisAddIn.Application.CreateItem(OlItemType.olMailItem);
reportEmail.Subject = subject;
reportEmail.To = TeamEmailAlias;
reportEmail.Send();
How can I delete the mail from "Sent Items" now ? 现在如何从“已发送邮件”中删除邮件?
thanks, 谢谢,
You just need to set up the DeleteAfterSubmit property of the MailItem class which allows to set a Boolean value that is True if a copy of the mail message is not saved upon being sent, and False if a copy is saved. 您只需要设置MailItem类的DeleteAfterSubmit属性,该属性允许设置一个布尔值,如果发送时未保存邮件的副本,则设置为True,如果保存副本,则设置为False。
MailItem reportEmail = Globals.ThisAddIn.Application.CreateItem(OlItemType.olMailItem);
reportEmail.DeleteAfterSubmit = true;
reportEmail.Subject = subject;
reportEmail.To = TeamEmailAlias;
reportEmail.Send();
There is a MailItem.Delete()
method, which should delete it from whatever folder it is in. This article on MSDN explains it, and also offers extra resources. 有一个
MailItem.Delete()
方法,该方法应该从它所在的任何文件夹中删除它MailItem.Delete()
上的这篇文章对此进行了解释,并提供了额外的资源。 You can also delete all items in a folder by using FolderName.Item(n).Delete()
. 您还可以使用
FolderName.Item(n).Delete()
删除文件夹中的所有项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.