VBA in Word to send out body of Word doc in Outlook

I have created a document in Word with a "Submit" button that uses VBA to send the document via Outlook as an attachment.  My preference would be to send the information included in the Word document in the body of the email message vs. an attachment.

Cut and Paste from developer in Word:

Private Sub Submit_Click()
Dim OL          As Object
Dim EmailItem   As Object
Dim Doc         As Document

Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save

With EmailItem
    .Subject = "Quote Request"
    .To = "wmimms@metalworkinggroup.com"
    .CC = "wnmimms@gmail.com"
    .Importance = olImportanceNormal
    .Attachments.Add Doc.FullName
    .Display
End With

Application.ScreenUpdating = True

Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing

End Sub

Open in new window

William MimmsAsked:
Who is Participating?
 
Bill PrewConnect With a Mentor Commented:
Give this a try.  I removed the attachment of the document, but you can certainly put that back if you want it both in the Body and attached.

I assumed you didn't want just the text, but wanted formatting and images as well.

Hopefully this gets you close...

Private Sub Submit_Click()
    Dim OL          As Object
    Dim EmailItem   As Object
    Dim Doc         As Document
    Dim Editor      As Object
    Const olFormatRichText = 3

    Application.ScreenUpdating = False
    Set OL = CreateObject("Outlook.Application")
    Set EmailItem = OL.CreateItem(olMailItem)
    Set Doc = ActiveDocument
    Doc.Content.Copy
    Doc.Save

    With EmailItem
        .Subject = "Quote Request"
        .To = "wmimms@metalworkinggroup.com"
        .CC = "wnmimms@gmail.com"
        .Importance = olImportanceNormal
    '    .Attachments.Add Doc.FullName
        .BodyFormat = olFormatRichText
        Set Editor = .GetInspector.WordEditor
        Editor.Content.Paste
        .Display
    End With

    Application.ScreenUpdating = True

    Set Doc = Nothing
    Set OL = Nothing
    Set EmailItem = Nothing

End Sub

Open in new window


»bp
0
 
William MimmsAuthor Commented:
Bill, Thanks so much!  Really appreciate the help!
0
 
Bill PrewCommented:
Welcome, glad that was useful.


»bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.