user3399836
user3399836

Reputation: 1

How to attach .msg from Outlook drafts folder to another e-mail?

Company policy prevents .SaveAs when my code drafts an e-mail with an attachment.
I save the drafts into the Outlook folder, but the goal is to attach that .msg to another message.

Is there any way via VBA to create an e-mail and add the attachment by accessing the Outlook drafts folder?

.SaveAs and olSaveAsType fail due to company policy; unable to change registry to enable prompttosaveas (Error 287).
Unable to create from template due to variable file attachment within initial message.

Upvotes: 0

Views: 104

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49397

You can copy the existing draft item in Outlook and continue setting it up for sending from the Drafts folder. The MailItem.Copy method creates another instance of an object, so the template saved in the Drafts folder will be remained as is.

Sub CopyItem() 
 Dim myNameSpace As Outlook.NameSpace
 Dim myFolder As Outlook.Folder 
 Dim myItem As Outlook.MailItem
 Dim myCopiedItem As Outlook.MailItem 
 
 Set myNameSpace = Application.GetNamespace("MAPI") 
 Set myFolder = myNameSpace.GetDefaultFolder(olFolderDrafts) 
 Set myItem = myFolder.Items(1)
 Set myCopiedItem = myItem.Copy 
 myCopiedItem.Send() 
 
End Sub 

Or you just can create a brand new email item in Outlook and then attach an existing item by using the Attachments.Add method which creates a new attachment in the Attachments collection. The source of the attachment. This can be a file (represented by the full file system path with a file name) or an Outlook item that constitutes the attachment. So, you just need to specify an Outlook item instance you want to be attached.

Upvotes: 0

Related Questions