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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.