Jay Webster
Jay Webster

Reputation: 179

excel vba - open outlook msg file then save as draft

I have the following code. What I would like to be able to do is open the .msg file, amend it to how I want it and then save it into the drafts folder (which is what it would normally happen if it was a new email message). The problem is, the below just saves back to the file, as expected...

Is there anyway that I can force it save into drafts? I have had a good google around and didnt find anything at all, so I am losing hope.

Sub TestMsg()
    Dim OL As Object
    Dim Msg As Object

    Set OL = CreateObject("Outlook.Application")
    Set Msg = OL.Session.OpenSharedItem("C:\Users\user\Desktop\Template.msg")
    Msg.Body = Msg.Body = " Test Message"
    Msg.Save

    Set Msg = Nothing
    Set OL = Nothing
End Sub

Thanks

Upvotes: 0

Views: 1030

Answers (1)

Tim Williams
Tim Williams

Reputation: 166126

https://learn.microsoft.com/en-us/office/vba/api/outlook.application.createitemfromtemplate

has this example:

Sub CreateFromTemplate2() 
 Dim MyItem As Outlook.MailItem 

 Set MyItem = Application.CreateItemFromTemplate("C:\statusrep.oft", _ 
                Application.Session.GetDefaultFolder(olFolderDrafts)) 
 MyItem.Save 
End Sub

Upvotes: 1

Related Questions