0

I have hundreds of different outlook .msg templates with similar bookmarks. I want to fill out these bookmarks so they get their data from a database using vba code.

Now, like in word documents, this is super easy, you simply write your vba code in your .dotm file, and later attach it to the the .docx file, check image below how its done in word.

Now my problem is, how can i do the same thing with outlook .msg files. I mean if you check the options - > add-ins for .msg file, the template option is not there. The .msg files are very similar to word files. Any idea how to do this. Any option is accepted, either via options or programatically?

Thanks in advance.

word document

Community
  • 1
  • 1
Mana
  • 1,925
  • 6
  • 39
  • 55

1 Answers1

0

MSG files are completely different from DOC files. You can however convert MSG files to DOC files using the Outlook Object Model - use Namespace.OpenSharedItem to open an MSG file as MailItem, then call MailItem.SaveAs(..., olDoc)

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Thanks for you answer, but not sure if it helped much, Do you know of any other way you can use VBA code on multiple .msg files by using a single macro file? The thing is, i have many .msg files with similiar bookmarks, which i would like to fill using a single macro file. would be pointless to make a new macro for every single .msg file – Mana Apr 22 '13 at 07:04
  • I am not sure what the problem is. Have you tried to use my suggestion? – Dmitry Streblechenko Apr 22 '13 at 17:01
  • do you know if the same thing is possible with excel documents. Lets say i have many .xlsx files, and i want to connect all of them to 1 single .xltm files, how would i do that? – Mana Apr 25 '13 at 11:42