Sending a Word Attachment through Outlook - VBA

B

blgsai

Word and Outlook are both integrated with our Document Management System (DM
5.0). I am using the code below to send the active document in Word as an
attachment in an Outlook mail item. The issue is the document path. If the
active documents path is saved on the users hard drive eg. C:\Testfile.txt,
it works fine but if it is a document that is saved in DM, it doesn't attach
it in the email. Am I missing something? See code below (Line 11, 12 & 13).
I am able to get the path - ::ODMA\PCDOCS\VAN01\2044141\1 and I tried adding
it in two different ways (line 11 and 12) but it doesn't add the attachment.
Yet, line 13 works.

Sub SendActiveDocument()

Dim DocName
DocName = ActiveDocument.FullName
MsgBox DocName

Dim myOutlook As Outlook.Application
Dim myoItem As Outlook.MailItem
Dim myAttachment As Outlook.Attachments

On Error Resume Next

Set myOutlook = New Outlook.Application
Set myoItem = myOutlook.CreateItem(olMailItem)
Set myAttachment = myoItem.Attachments

11: myAttachment.Add Source:=Name, Type:=olByValue, Position:=1,
DisplayName:="TEST"
12: 'myAttachment.Add "::ODMA\PCDOCS\VAN01\2044141\1", olByValue, 1, "TEST"
13: 'myAttachment.Add "C:\testfile.txt", olByValue, 1, "TEST"

'Let user manually send email after adding recepients, subject and body
myoItem.Display

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top