Help: Need to send active document as attachment via Outlook

P

PiaD

I need a macro that automatically sends the current active document via email
to one specific user. It sounds easy, but I have not found anything that
meets this exactly.

Options I have found include: MsoEnvelope Object and SendForReview Method.
They provide the following hurdles: MsoEnvelope does not send document as
attachment, only the document content as the body of the email.
SendForReview sends the document with the Tracking status ON, which I do NOT
want. Any help overcoming this or any other options to solve my issues would
be great. I will take anyway to send an attachment to a specified user.

I have tried using:
Sub SendMail
With Application.ActiveDocument.MailEnvelope
.Introduction = "Please read this and send me your comments."
'Return a Microsoft Outlook MailItem object that
'you can use to send the document.
With .Item
.Recipients.Add "(e-mail address removed)"
.Subject = "Here is the document."
'The body of this message will be
'the content of the active document.
.Send
End Sub

OR

Sub WebReview()
ThisDocument.SendForReview _
Recipients:="(e-mail address removed); amy jones", _
Subject:="Please review this document.", _
ShowMessage:=False, _
IncludeAttachment:=True
End Sub
 
G

Graham Mayor

Does the following work for you?

Sub SendDocumentAsAttachment()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
'You'll need to add the Outlook Object Library to VBA Tools References
Dim oItem As Outlook.MailItem
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then 'Document has not been saved
ActiveDocument.Save 'so save it
End If
'see if Outlook is running and if so turn your attention there
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then 'Outlook isn't running
'So fire it up
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Open a new e-mail message
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
.To = "(e-mail address removed)" 'send to this address
.Subject = "New subject" 'This is the message subject
.Body = "See attached document" ' This is the message body text
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Send
'**********************************
'If you want to view the message before it goes
'change the line above from .Send to .Display
'Otherwise the message is sent straight to the Outbox
'and if you have Outlook set to send mail immediately,
'it will simply be Sent
'with no obvious sign that Outlook has operated.
'Apart from the copy in the Outlook Sent folder
'**********************************
End With
If bStarted Then 'If the macro started Outlook, stop it again.
oOutlookApp.Quit
End If
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

PiaD

Thanks for the help. I am pretty new at this and greatly appreciate any
guidance!

I am using Word 2003 and when I run that macro I get the following error:
"Run time error 446. Object Does not support Named Arguements"

for the line:
..Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
 
P

PiaD

Thanks for pointing me in the right direction on this issue. I was able to
move forward with your guidance and successfully send an email with an
attachment to outlook. I just added a new post to fine tune things further.
 

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