简体   繁体   English

C#Outlook插件-在未发送该电子邮件的情况下将新项目创建到“已发送”框中

[英]C# Outlook Plugin - Create new item into Sent Box without send that email

I'm writing a plugin for outlook, I want to create new item into Sent Box but i don't want to send it, just save it to Sent Box. 我正在为Outlook编写一个插件,我想在Sent Box中创建新项目,但我不想发送它,只需将其保存到Sent Box中即可。

Pls, help me! 请帮助我!

Outlook Object Model will not, generally, let you create a message in the sent state - MailItem.Sent property is read-only. 通常,Outlook对象模型不会让您在发送状态下创建消息MailItem.Sent属性为只读。 Even on the MAPI level (C++ or Delphi), MSGFLAG_UNSENT bit can be removed from the PR_MESSAGE_FLAGS property only before the message is saved for the very first time. 即使在MAPI级别(C ++或Delphi)上,也只能在第一次保存消息之前从PR_MESSAGE_FLAGS属性中删除MSGFLAG_UNSENT位。 The only kind of item created by OOM in the sent state is a post item, so in theory, you can create a post item, save it, reset its MessageClass property to "IPM.Note", dereference it, reopen by the entry id - you will now have a MailItem in the sent state. 由OOM在发送状态下创建的唯一一种项目是发布项目,因此从理论上讲,您可以创建一个发布项目,将其保存,将其MessageClass属性重置为"IPM.Note",取消引用,然后通过条目ID重新打开-现在,您将拥有一个已发送状态的MailItem。 You will not have to set all the sender and recipient properties (about a dozen of them) and remove post specific properties - take a look at a sent message with OutlookSpy (click IMessage button). 您将不必设置所有发件人和收件人属性(大约十二个),也不必删除特定于帖子的属性-使用OutlookSpy查看已发送的邮件(单击IMessage按钮)。

If using Redemption (any language) is an option, it can create a fake sent message easily: 如果选择使用“ 兑换” (任何语言),它可以轻松创建虚假的已发送邮件:

Set MySession = CreateObject("Redemption.RDOSession")
MySession.MAPIOBJECT = Application.Session.MAPIOBJECT
Set Folder = MySession.GetDefaultFolder(olFolderSentMail)
Set msg = Folder.Items.Add("IPM.Note")
msg.Sent = True
msg.Recipients.AddEx "The user", "user@domain.demo", "SMTP", olTo
msg.Sender = MySession.CurrentUser
msg.SentOnBehalfOf = MySession.CurrentUser
msg.subject = "Test sent message"
msg.Body = "test body"
msg.SentOn = Now
msg.ReceivedTime = Now
msg.Save

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM