Results 1 to 6 of 6

Thread: Document Content to Body of Email
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    May 2015
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Document Content to Body of Email

    Good morning,

    Hoping all you wonderful folks out there can help me, I am trying to find a vba script to open a word document and copy the contents and create a new email message and use the document contents as the email body, is this possible using vba?

    Thanks

  2. #2
    New Member
    Join Date
    May 2015
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Document Content to Body of Email

    Edit - This would need to keep the Word formatting rather than just copy the text over

  3. #3
    Board Regular
    Join Date
    Jul 2014
    Location
    Memphis, TN
    Posts
    2,673
    Post Thanks / Like
    Mentioned
    11 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Document Content to Body of Email

    Quote Originally Posted by jonnyp138 View Post
    Edit - This would need to keep the Word formatting rather than just copy the text over
    Formatting in Outlook does have most the same elements as Word but not all.
    Why not Share the Word document by Email?
    Excel 2013, 2016 with PowerBI
    Knowing that it can be done is half the battle!

  4. #4
    New Member
    Join Date
    May 2015
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Document Content to Body of Email

    The email is an escalation email and they just want the content of the word template inserting into the body of the email if that makes sense

  5. #5
    New Member
    Join Date
    May 2015
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Document Content to Body of Email

    Quote Originally Posted by SpillerBD View Post
    Formatting in Outlook does have most the same elements as Word but not all.
    Why not Share the Word document by Email?
    Quote Originally Posted by SpillerBD View Post
    Formatting in Outlook does have most the same elements as Word but not all.
    Why not Share the Word document by Email?
    I have found the following which seems to work but if it is ran more than once i.e in a loop until all escalations have been dealt with then the 2nd time round I get a runtime error saying the document is locked for editing and cant figure out why?

    Set oWordApp = CreateObject("Word.Application")
    Set oWordDoc = oWordApp.Documents.Open("C:\Temp\Reminder.docx", ReadOnly:=True)


    oWordDoc.Content.Copy
    Set oOutApp = CreateObject("Outlook.Application")
    Set oMailItem = oOutApp.CreateItem(0)


    With oMailItem
    .To = ""
    .Subject = "Level 2 On Hold Escalation Email"
    .Display
    End With


    Set oMailWordDoc = oOutApp.ActiveInspector.WordEditor


    oMailWordDoc.Application.Selection.Paste

    oWordApp.Quit
    Set oMailItem = Nothing
    Set oMailWordDoc = Nothing
    Set oOutApp = Nothing

  6. #6
    Board Regular
    Join Date
    Jul 2014
    Location
    Memphis, TN
    Posts
    2,673
    Post Thanks / Like
    Mentioned
    11 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Document Content to Body of Email

    If the content is static and just written up in a Word Document, it might be simpler to make that text an Auto Text or Quick Part.

    As far as the error in the loop, it appears it is trying to re-open the Word document. Open the Word document before the Loop and make sure you .Close the document before the procedure finishes. Having to Open/Close it will slow it down if you have a lot of loop executions.
    Excel 2013, 2016 with PowerBI
    Knowing that it can be done is half the battle!

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •