Share via

VBA code for send e-mail button

Anonymous
2011-08-24T17:37:12+00:00

Hello,

I'm trying to find some Word VBA code that I can use to send an active document as an e-mail attachment.

  • I will attach it to a button
  • We're using Windows 7 and Office 2010

Can anyone help me?

Thanks

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-08-26T14:28:49+00:00

Although the methods and properties for routing slips are still present in Word VBA, they cannot be used any more starting with Word 2007.

Try this instead:

Sub Test()

    Options.SendMailAttach = True

    ActiveWindow.EnvelopeVisible = True

    With ActiveDocument.MailEnvelope.Item

        .Subject = "Testing 123"

        .Recipients.Add "******@somewhere.com"

    End With

End Sub

Was this answer helpful?

0 comments No comments

18 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-12-13T05:58:39+00:00

    It's a simple as copy and paste into the Word VBA editor, as the code is listed for you (don't forget you'll need the function from the linked page to complete the code), but the document must be saved whatever the process. Even the simple two line code saves the document. - take a look at the attachment.  You can't send the content of your PCs memory.

    See Example Template for a working version of the code I posted. Create a new document from the template. Click the button. An Outlook message is created with the settings in the code, and then you are prompted to choose whether to create another document.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-12-12T14:29:56+00:00

    >>To send an document as an attachment, it is necessary to be able to specify the field name so that it can be attached and thus it is necessary to save the document.<<

    Thanks, I'll try that.

    But the

    Options.SendMailAttach = True

    ActiveDocument.SendMail

    code sends the document without saving it (this is what the 'email' command in the QAT does.).  I was hoping this could be as simple as that.

    My boss created a similar 'email-me' button in a PDF form (no saving of the form required!), and I was trying to replicate the same behavior without having to change platforms!

    jk

    Was this answer helpful?

    0 comments No comments