dcsimg
Results 1 to 4 of 4

Thread: [Word] macro for HTML formatted email

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    3

    [Word] macro for HTML formatted email

    I have working VB for a Text Rich Format email message.... see below.

    I am trying to do a couple of things.

    1. I would like the email that is opened in Outlook to be in HTML format.
    2. Use data that is inputted into a specific field to be incorporated into the subject line of the email message.
    3. Create "hard stops" within the Word document that would prevent someone from clicking the "Submit" button within the document until the Word document is completed.

    I have attached the Word document as .doc will need to change to .docm


    Thanks,

    Bill


    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.SaveAs ("Quote Request")

    With EmailItem
    .Subject = "Quote Request"
    .to = "quote@metalworkinggroup.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
    Attached Files Attached Files

  2. #2
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    463

    Re: [Word] macro for HTML formatted email

    For your question 1, see this link:

    https://docs.microsoft.com/en-us/pre...0(v=office.11)

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    3

    Re: [Word] macro for HTML formatted email

    Thank you,

    I found that earlier and pasted olFormatHTML for olFormatRichText but get an error. I wasn't sure how much of this should be incorporated into what I posted above and where. Sorry.... really new to all this



    Sub CreateHTMLMail()
    'Creates a new e-mail item and modifies its properties.

    Dim olApp As Outlook.Application
    Dim objMail As MailItem
    Set olApp = Outlook.Application
    'Create mail item
    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
    'Set body format to HTML
    .BodyFormat = olFormatHTML
    .HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
    .Display
    End With

    End Sub

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    3

    Re: [Word] macro for HTML formatted email

    Thank you,

    I found that earlier and pasted olFormatHTML for olFormatRichText but get an error. I wasn't sure how much of this should be incorporated into what I posted above and where. Sorry.... really new to all this



    Sub CreateHTMLMail()
    'Creates a new e-mail item and modifies its properties.

    Dim olApp As Outlook.Application
    Dim objMail As MailItem
    Set olApp = Outlook.Application
    'Create mail item
    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
    'Set body format to HTML
    .BodyFormat = olFormatHTML
    .HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
    .Display
    End With

    End Sub

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width