troubleshooting Question

Issue to message

Avatar of Peter Chan
Peter ChanFlag for Hong Kong asked on
VB ScriptMicrosoft OfficeVBAMicrosoft Excel
1 Comment1 Solution89 ViewsLast Modified:
Hi,
Message was not sent properly (with HTML format). If it is not using HTML format below, everything is fine. Why?
Sub Send_email()
    On Error GoTo ErrHandler
    
    ' SET Outlook APPLICATION OBJECT.
    Dim objOutlook As Object
    Set objOutlook = CreateObject("Outlook.Application")
    
    ' CREATE EMAIL OBJECT.
    Dim objEmail As Object
    Set objEmail = objOutlook.CreateItem(olMailItem)

    With objEmail
        .to = "??@gmail.com"
        .Subject = "This is a test message on Jan 31"
        '.Body = "Hi there"
        '.Display        ' DISPLAY MESSAGE.
        .BodyFormat = olFormatHTML
        .HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY> Please enter the message text here. </BODY></HTML>"
         .send
    End With
    
    ' CLEAR.
    Set objEmail = Nothing:    Set objOutlook = Nothing
        
ErrHandler:
    '
End Sub
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros