Automated moving of attached messages to the inbox in Outlook

◇◆丶佛笑我妖孽 提交于 2019-12-11 04:28:13

问题


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.

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?


回答1:


Here is how I would do it. However, I will give you pieces of code which you will have to merge together.

Logic:

  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

Code for Extracting attachments: Covered HERE

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

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.



来源:https://stackoverflow.com/questions/18902192/automated-moving-of-attached-messages-to-the-inbox-in-outlook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!