问题
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:
- 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
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