How to create .HTMLBody tables for Outlook Email (1 Viewer)

jsdba

Registered User.
Local time
Today, 14:15
Joined
Jun 25, 2014
Messages
165
How can i format .HTMLBody message into tables. I know i need to use <table></table> html tags but i'm not sure how.

e.g
---------------------------------------------------------------
|Fields Changes | Project Address |On Hold |
---------------------------------------------------------------
|strControlName | strProjectAddress |strApproveStatus|
---------------------------------------------------------------

Code:
    .HTMLBody = "<HTML><BODY STYLE=font-size: 16pt; font-family: Calibri>" _
                & "<b>Fields Changed: </b>" & " " & strControlName & "<br><br>" _
                & "<b>Project Address: </b>" & " " & strProjectAddress & " " & ProjectBorough & "<br><br>" _
                & "<b>On Hold: </b>" & strApproveStatus & "<br>" _
                & "<b>Project #: </b>" & ProjectNum & "<br>" _
                & "<b>Apptoved/Rejected: </b>" & TaskStatus & "<br>" _
                & "<b>Field Staff: </b>" & FieldManager & "<br>" _
                & "<b>Assign Date: </b>" & AssignDate & "<br>" _
                & "<b>Next Expected Action Date: </b>" & NEAD & "<br>" _
                & "<b>Task: </b>" & TaskDesc & "<br>" _
                & "<b>Task Description: </b>" & TaskDescExt & "<br>" _
                & "<b>Application #: </b>" & AppNum & "<br>" _
                & "<b>Submission Date: </b>" & SubmissionDate & "<br>" _
                & "<b>Agency: </b>" & Agency & "<br>" _
                & "<b>Agency Office: </b>" & AgencyOffice & "<br>" _
                & "<b>Task Note: </b>" & TaskNote & "<br>" _
                & "<b>Note To John: </b>" & JohnMemo & "<br>" _
                & "<b>Status: </b>" & strStatus & "<br></BODY></HTML>"

Code runs in Access2010
 

BlueIshDan

&#9760;
Local time
Today, 15:15
Joined
May 15, 2014
Messages
1,122
Not sure what your question is looking for exactly, but this is how you format tables in HTML

Code:
<table>

	<tr>
		<td>Field Changes</td>
		<td>Project Address</td>
		<td>On Hold</td>
	</tr>

	<tr>
		<td>strControlName</td>
		<td>strProjectAddress</td>
		<td>strApproveStatus</td>
	</tr>

	<tr>
		<td>strControlName</td>
		<td>strProjectAddress</td>
		<td>strApproveStatus</td>
	</tr>

</table>
 

ByteMyzer

AWF VIP
Local time
Today, 11:15
Joined
May 3, 2004
Messages
1,409
Try changing your code to:
Code:
    .HTMLBody = "<HTML><BODY STYLE=font-size: 16pt; font-family: Calibri>" _
                & "<table><tr><th>Fields Changed:</th><td>" & strControlName & "</td></tr>" _
                & "<tr><th>Project Address:</th><td>" & strProjectAddress & " " _
                & ProjectBorough & "</td></tr>" _
                & "<tr><th>On Hold:</th><td>" & strApproveStatus & "</td></tr>" _
                & "<tr><th>Project #:</th><td>" & ProjectNum & "</td></tr>" _
                & "<tr><th>Apptoved/Rejected:</th><td>" & TaskStatus & "</td></tr>" _
                & "<tr><th>Field Staff:</th><td>" & FieldManager & "</td></tr>" _
                & "<tr><th>Assign Date:</th><td>" & AssignDate & "</td></tr>" _
                & "<tr><th>Next Expected Action Date:</th><td>" & NEAD & "</td></tr>" _
                & "<tr><th>Task:</th><td>" & TaskDesc & "</td></tr>" _
                & "<tr><th>Task Description:</th><td>" & TaskDescExt & "</td></tr>" _
                & "<tr><th>Application #:</th><td>" & AppNum & "</td></tr>" _
                & "<tr><th>Submission Date:</th><td>" & SubmissionDate & "</td></tr>" _
                & "<tr><th>Agency:</th><td>" & Agency & "</td></tr>" _
                & "<tr><th>Agency Office:</th><td>" & AgencyOffice & "</td></tr>" _
                & "<tr><th>Task Note:</th><td>" & TaskNote & "</td></tr>" _
                & "<tr><th>Note To John:</th><td>" & JohnMemo & "</td></tr>" _
                & "<tr><th>Status:</th><td>" & strStatus & "</td></tr></table></BODY></HTML>"
 

jsdba

Registered User.
Local time
Today, 14:15
Joined
Jun 25, 2014
Messages
165
ByteMyzer thank you, that certainly the direction i want to take it. How can i left justify the fields (left column).
 

Attachments

  • Untitled.png
    Untitled.png
    16.3 KB · Views: 292

BlueIshDan

&#9760;
Local time
Today, 15:15
Joined
May 15, 2014
Messages
1,122
if I'm not mistaken, you didnt put <th style="text-align: left">
 

BlueIshDan

&#9760;
Local time
Today, 15:15
Joined
May 15, 2014
Messages
1,122
your first TR (ROW) should contain all of your TH (Headers)
Each TR after should contain each of your records, in order respective to the headers.

Code:
<table>

	<!-- HEADERS -->
	<tr>
		<th>H1</th>
		<th>H2</th>
		<th>H3</th>
		<th>H4</th>
	</tr>
	
	<!-- RECORD 1 -->
	<tr>
		<td>Data1</td>
		<td>Data2</td>
		<td>Data3</td>
		<td>Data4</td>
	</tr>
	
	<!-- RECORD 2 -->
	<tr>
		<td>Data1</td>
		<td>Data2</td>
		<td>Data3</td>
		<td>Data4</td>
	</tr>
	
	<!-- RECORD 3 -->
	<tr>
		<td>Data1</td>
		<td>Data2</td>
		<td>Data3</td>
		<td>Data4</td>
	</tr>

</table>
 

jsdba

Registered User.
Local time
Today, 14:15
Joined
Jun 25, 2014
Messages
165
Tried <th style="text-align: left">...still getting an error. see Code Error.
Also the table output is exactly what i need. I dont exactly need a table but more two columns with borders. All i'm trying to do is left align the text in the column on the left. see Table Output.
 

Attachments

  • Table Output.png
    Table Output.png
    16.9 KB · Views: 200
  • Code Error.png
    Code Error.png
    68.4 KB · Views: 189

BlueIshDan

&#9760;
Local time
Today, 15:15
Joined
May 15, 2014
Messages
1,122
try <th style="text-align: left;">

Some html parsers don't like when you don't finish with ;
 

BlueIshDan

&#9760;
Local time
Today, 15:15
Joined
May 15, 2014
Messages
1,122
Also to save room, you may be able to use this within your header tags:
Code:
.HTMLBody = "<HTML><head><style> th, td { text-align: left;}</style></head><BODY STYLE=......" etc
 
Last edited:

Users who are viewing this thread

Top Bottom