• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Posting files via Outlook

I am using Excel VBA

The following code will post a word document to Outlook.
However the word document is posted inside an email message.
Is there anyway of posting the word document as itself to Outlook (for instance when you drag a document to Outlook using the mouse then it is posted as itself)

Sub deleteme()
  Dim ol As New Outlook.Application
  Dim ns As Outlook.NameSpace
  MyPath = "C:\temp\"
myname = "dump"

  'Return a reference to the MAPI layer
  Set ns = ol.GetNamespace("MAPI") 'tg 22/09 sometimes causes EXcel failure
  'Point to Public Folder
  Set PubFolder = ns.Folders("Public Folders").Folders("All Public Folders").Folders("Projects")
     Set newPost = PubFolder.Items.Add(olPostItem)
        'Post it
          With newPost
            .Subject = myname
            .Attachments.Add MyPath & myname, olByValue, , myname
          End With

End Sub
1 Solution
You may insert document as attachment or you may create an attachment and copy the contents of word document inside. As far as I can understand you are trying to do the second?

So make use of Word.Application object. From Word you can perform File->Save to Exchange folder... command. Or using VBA


The another way is to do copy the contents of Word Document (something like
and then in Outlook perform Paste with the help of CommandBars object.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now