Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-30-2015, 10:51 AM   #1
jsdba
Newly Registered User
 
Join Date: Jun 2014
Location: NY, USA
Posts: 152
Thanks: 37
Thanked 2 Times in 2 Posts
jsdba is on a distinguished road
How to create .HTMLBody tables for Outlook Email

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

jsdba is offline   Reply With Quote
Old 11-30-2015, 11:01 AM   #2
BlueIshDan
 
Join Date: May 2014
Posts: 1,122
Thanks: 155
Thanked 160 Times in 156 Posts
BlueIshDan is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

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>
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Blue's Age Poll:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Animated Sorting:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Mining File Directories:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
GetSubFolders:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

GetFileLines:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

FindSimilarValues:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Move (Avoid moving objects game):
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
BlueIshDan is offline   Reply With Quote
Old 11-30-2015, 11:06 AM   #3
ByteMyzer
AWF VIP
 
Join Date: May 2004
Location: United States
Posts: 1,385
Thanks: 0
Thanked 48 Times in 43 Posts
ByteMyzer is a jewel in the rough ByteMyzer is a jewel in the rough ByteMyzer is a jewel in the rough ByteMyzer is a jewel in the rough
Re: How to create .HTMLBody tables for Outlook Email

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>"

ByteMyzer is offline   Reply With Quote
The Following User Says Thank You to ByteMyzer For This Useful Post:
jsdba (11-30-2015)
Old 11-30-2015, 11:23 AM   #4
jsdba
Newly Registered User
 
Join Date: Jun 2014
Location: NY, USA
Posts: 152
Thanks: 37
Thanked 2 Times in 2 Posts
jsdba is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

ByteMyzer thank you, that certainly the direction i want to take it. How can i left justify the fields (left column).
Attached Images
File Type: png Untitled.png (16.3 KB, 100 views)
jsdba is offline   Reply With Quote
Old 11-30-2015, 01:12 PM   #5
BlueIshDan
 
Join Date: May 2014
Posts: 1,122
Thanks: 155
Thanked 160 Times in 156 Posts
BlueIshDan is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

<td style="text-align: left">
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Blue's Age Poll:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Animated Sorting:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Mining File Directories:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
GetSubFolders:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

GetFileLines:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

FindSimilarValues:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Move (Avoid moving objects game):
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
BlueIshDan is offline   Reply With Quote
Old 12-01-2015, 11:13 AM   #6
jsdba
Newly Registered User
 
Join Date: Jun 2014
Location: NY, USA
Posts: 152
Thanks: 37
Thanked 2 Times in 2 Posts
jsdba is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

Quote:
Originally Posted by BlueIshDan View Post
<td style="text-align: left">
Gives me syntax error. i want left align <th>
Is there anything else i can try?
Attached Images
File Type: png Untitled1.png (41.8 KB, 73 views)
jsdba is offline   Reply With Quote
Old 12-02-2015, 02:57 AM   #7
BlueIshDan
 
Join Date: May 2014
Posts: 1,122
Thanks: 155
Thanked 160 Times in 156 Posts
BlueIshDan is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

if I'm not mistaken, you didnt put <th style="text-align: left">

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Blue's Age Poll:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Animated Sorting:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Mining File Directories:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
GetSubFolders:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

GetFileLines:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

FindSimilarValues:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Move (Avoid moving objects game):
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
BlueIshDan is offline   Reply With Quote
Old 12-02-2015, 02:58 AM   #8
BlueIshDan
 
Join Date: May 2014
Posts: 1,122
Thanks: 155
Thanked 160 Times in 156 Posts
BlueIshDan is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

That table is not structured right.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Blue's Age Poll:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Animated Sorting:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Mining File Directories:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
GetSubFolders:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

GetFileLines:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

FindSimilarValues:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Move (Avoid moving objects game):
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
BlueIshDan is offline   Reply With Quote
Old 12-02-2015, 03:01 AM   #9
BlueIshDan
 
Join Date: May 2014
Posts: 1,122
Thanks: 155
Thanked 160 Times in 156 Posts
BlueIshDan is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

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>
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Blue's Age Poll:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Animated Sorting:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Mining File Directories:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
GetSubFolders:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

GetFileLines:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

FindSimilarValues:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Move (Avoid moving objects game):
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
BlueIshDan is offline   Reply With Quote
Old 12-02-2015, 06:30 AM   #10
jsdba
Newly Registered User
 
Join Date: Jun 2014
Location: NY, USA
Posts: 152
Thanks: 37
Thanked 2 Times in 2 Posts
jsdba is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

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.
Attached Images
File Type: png Table Output.png (16.9 KB, 83 views)
File Type: png Code Error.png (68.4 KB, 50 views)
jsdba is offline   Reply With Quote
Old 12-02-2015, 06:52 AM   #11
BlueIshDan
 
Join Date: May 2014
Posts: 1,122
Thanks: 155
Thanked 160 Times in 156 Posts
BlueIshDan is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

try <th style="text-align: left;">

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

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Blue's Age Poll:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Animated Sorting:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Mining File Directories:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
GetSubFolders:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

GetFileLines:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

FindSimilarValues:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Move (Avoid moving objects game):
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
BlueIshDan is offline   Reply With Quote
The Following User Says Thank You to BlueIshDan For This Useful Post:
jsdba (12-02-2015)
Old 12-02-2015, 06:57 AM   #12
BlueIshDan
 
Join Date: May 2014
Posts: 1,122
Thanks: 155
Thanked 160 Times in 156 Posts
BlueIshDan is on a distinguished road
Re: How to create .HTMLBody tables for Outlook Email

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

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Blue's Age Poll:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Animated Sorting:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Mining File Directories:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
GetSubFolders:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

GetFileLines:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

FindSimilarValues:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Move (Avoid moving objects game):
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by BlueIshDan; 12-02-2015 at 07:48 AM.
BlueIshDan is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Send a specific email from outlook to all email addresses within a quiery Ads General 6 01-22-2014 06:42 AM
Create Report, Email through Outlook jerryc126 Reports 7 09-15-2011 05:56 PM
Add value from field in a form into .HTMLbody of an email diarmaidbrown Modules & VBA 6 07-09-2011 09:20 AM
Create email in Outlook Express 429 error RV Modules & VBA 1 04-29-2004 02:12 AM
Outlook And HTMLBody MattS Modules & VBA 2 08-27-2003 06:27 AM




All times are GMT -8. The time now is 06:20 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World