Search

Email Automation using VBA without outlook. Send emails via Gmail, Yahoo or Microsoft Accounts


This blog is part of below video tutorial Email Automation using VBA without outlook. Send emails via Gmail, Yahoo or Microsoft Accounts
https://www.youtube.com/watch?v=nj8mU3ecwsM

Please support by subscribing to our channel and sharing them with your friends.

If you have any questions/feedback/tutorial request, please you can email me directly vbaa2z.team@gmail.com or comment on YouTube Video (blog comments are not actively monitored).




If you're not familiar with HTML, use this simple site where you type in the email body and insert a table within the email. http://htmleditor.in/index.html


Now use VBA to loop through you records/table/cells using VBA and construct variables for example: 
<tr>
  <td>
    1</td>
  <td>
    Jessica Miles</td>
  <td>
    $4,456,543.00</td>
</tr>

VBA Code sample:- use this sort of function to convert your records to HTML tag and use them in your send email code.

'<tr>
'  <td>
'    1</td>
'  <td>
'    Jessica Miles</td>
'  <td>
'    $4,456,543.00</td>
'</tr>

Function curR_html(field1$, field2$, field3$) As String

Dim x$

x = "<tr>"
x = x & vbNewLine & "  <td>"
x = x & vbNewLine & "    " & field1$ & "</td>"
x = x & vbNewLine & "  <td>"
x = x & vbNewLine & "    " & field2$ & "</td>"
x = x & vbNewLine & "  <td>"
x = x & vbNewLine & "    " & field3$ & "</td>"
x = x & vbNewLine & "</tr>"

curR_html = x

End Function

Sub test_curR_html()
  Debug.Print curR_html("3", "Andrew Dow", "$1,345,544.00")
End Sub


Full email body - HTML Code sample: 
<html>
 <head>
  <title></title>
 </head>
 <body>
  <p>
   Hi Pamai,</p>
  <p>
   this is sample body line1.</p>
  <p>
   this is sample body line2.</p>
  <p>
   &nbsp;</p>
  <table border="1" cellpadding="1" cellspacing="1" style="width: 500px">
   <tbody>
    <tr>
     <td>
      ID</td>
     <td>
      Clients</td>
     <td>
      Amount</td>
    </tr>
    <tr>
     <td>
      1</td>
     <td>
      Jessica Miles</td>
     <td>
      $4,456,543.00</td>
    </tr>
    <tr>
     <td>
      2</td>
     <td>
      Adam Lam</td>
     <td>
      $6,222,221.00</td>
    </tr>
   </tbody>
  </table>
  <p>
   Thanks and regards,</p>
  <p>
   Lung</p>
 </body>
</html>



No comments:

Post a Comment

Note: only a member of this blog may post a comment.