自动将附件中的邮件移动到Outlook中的收件箱 [英] Automated moving of attached messages to the inbox in Outlook

查看:173
本文介绍了自动将附件中的邮件移动到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.

逻辑:

  1. 提取附件并保存为C:\
  2. 使用方法CreateItemFromTemplate()打开.msg文件.有关它的更多信息这里
  3. 将邮件移至相关文件夹
  1. Extract the attachment and save it to say C:\
  2. Use the method CreateItemFromTemplate() to open the .msg file. More about it HERE
  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆