Joseph
Joseph

Reputation: 21

Automated moving of attached messages to the inbox in Outlook

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?

Upvotes: 1

Views: 1518

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149295

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.

Upvotes: 3

Related Questions