自动将附件中的邮件移动到Outlook中的收件箱 [英] Automated moving of attached messages to the inbox in Outlook
问题描述
我经常收到以Outlook格式的.msg文件形式发送的转发电子邮件.这些电子邮件作为附件从另一台交换服务器转发.如果我将附件中的邮件拖到我的收件箱中,它们会像其他电子邮件一样显示.我想找到一种自动方式,将这些附加的电子邮件提取到我的收件箱中,并删除包含.msg文件的原始邮件.
I regularly receive forwarded emails that come as Outlook formatted .msg files. These emails were forwarded as attachments from another exchange server. If I drag the attached messages to my Inbox, they show up just like any other email. I would like to find an automated way to extract these attached emails to my inbox and delete the original messaged that contained the .msg file.
我确定可以通过将规则与Outlook VBA结合使用来完成此操作,但是我缺乏从头开始编写此代码的技能.
I’m sure this can be accomplished through a rule in conjunction with an Outlook VBA, but I lack the skill to write this code from scratch.
有什么指针或示例代码可以帮助我入门吗?
Any pointers or sample code to get me started?
推荐答案
这就是我的方法.但是,我将为您提供一些必须合并在一起的代码.
Here is how I would do it. However, I will give you pieces of code which you will have to merge together.
逻辑:
- 提取附件并保存为
C:\
- 使用方法
CreateItemFromTemplate()
打开.msg文件.有关它的更多信息这里 - 将邮件移至相关文件夹
- Extract the attachment and save it to say
C:\
- Use the method
CreateItemFromTemplate()
to open the .msg file. More about it HERE - Move the message to the relevant folder
提取附件的代码:涵盖了在这里
用于打开.msg
文件的代码:
Code for opening the .msg
file:
Sub CreateFromTemplate()
Dim MyItem As Outlook.MailItem
Set MyItem = Application.CreateItemFromTemplate("C:\Blah Blah.msg")
MyItem.Display
End Sub
现在您已经拥有.msg
的句柄,即MyItem
,只需将其移至相关文件夹,然后删除原始电子邮件
Now you have the handle to the .msg
i.e MyItem
, simply move it to the relevant folder and then delete the original email
Code for moving to a different folder: Covered HERE. If you search google, you will get more sample codes for this.
希望这会使您走上正确的道路.
Hope this gets you on the right path.
这篇关于自动将附件中的邮件移动到Outlook中的收件箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!