Results 1 to 4 of 4

Thread: VBA to Paste clipboard contents under image in email

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Here is a very simple example of using HTML for the body. Place your logo image on an online server. In this example I am using imgur.com and the image is from helping someone with hex colors in Excel.

        Dim oApp As Outlook.Application
        Dim oMail As Outlook.MailItem
        Dim emailBody As String
    
    
        emailBody = "<html>"
        emailBody = emailBody & "<table>"
        emailBody = emailBody & "    <tr>"
        emailBody = emailBody & "        <th><div style=""text-align:left""><img src='https://i.imgur.com/GyY1yml.png' width=100 height=100></div></th>"
        emailBody = emailBody & "    </tr>"
        emailBody = emailBody & "    <tr>"
        emailBody = emailBody & "        <td>"
        emailBody = emailBody & "            <p>This is the email body that we want to send in the email so the person getting the email can read it</p>"
        emailBody = emailBody & "        </td>"
        emailBody = emailBody & "    </tr>"
        emailBody = emailBody & "</table>"
        emailBody = emailBody & "</html>"
    
    
    
    
        Set oApp = CreateObject("Outlook.Application")
        
        Set oMail = oApp.CreateItem(olMailItem)
        On Error Resume Next
        With oMail
            .To = ***** the email address to send the email to **********
            .Subject = "Test HTML Email with Logo"
            .HTMLBody = emailBody
            
            If Err = 0 Then
                ' send if the previous commands ran ok
                .Send
            End If
        
        End With
        Set oMail = Nothing
    
    
        oApp.Quit
        Set oApp = Nothing
    The email as it is received
    Attached Images Attached Images

Posting Permissions

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