Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble with email formatting

Status
Not open for further replies.

sm43

Programmer
Dec 1, 2002
155
0
0
US
Hi,
I'm using CDONTSMail to send myself and a couple of important people an email that includes content from a database table..

I include the data from the database to be presented in columnar form in the email. I'm having trouble with the width. I've included five-six columns from the database and the width of the email has gotten long. As a result rows of data get wrapped, which is not what I want. I would like each row to appear on one line only, because there are column headers. The email looks really awkward and obscure that way. Here is my code:


<!--#include file=&quot;incl/data.asp&quot;-->

sql = &quot;....&quot;

Set MyRS = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

MyRS.CursorType=adOpenDynamic
MyRS.CursorLocation = adUseClient

MyRs.Open sql, MyConn


Set sendmail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)

sendmail.From = &quot;saadm_wharton@yahoo.com&quot;

sendmail.To = &quot;saadm_wharton@yahoo.com; emailaddress2; emailaddress3&quot;

sendmail.Subject = &quot;Daily Report - &quot; & Date

BodyText = &quot;Changes made today in the database&quot;

Do While NOT MyRS.EOF

BodyText = BodyText & MyRS(&quot;FieldsChanged&quot;)

MyRS.MoveNext
Loop


sendmail.Body = BodyText


'this sets mail priority.... 0=low 1=normal 2=high
sendmail.Importance = 2

sendmail.Send

%>



Thanks in-advance for your help..


Saad
 
I'm not sure wether that is possible in cdonts but try sending the email in HTML format and put your recordset in a html table

greetings
 
have you tried to just add a Carriage return to the bodytext loop
ie
Do While NOT MyRS.EOF

BodyText = BodyText & MyRS(&quot;FieldsChanged&quot;) & vbcrlf

MyRS.MoveNext
Loop I dare to learn more
admin@onpntwebdesigns.com
 
I'm sorry, the correct code for the BodyText loop, onpnt, is


BodyText = &quot;Following are the details of changes that were made today to data in Chester Charter Community School database:&quot; & vbcrlf & vbcrlf & &quot;Information Changed &quot; & vbtab & vbtab & vbtab & &quot;Done By &quot; & vbtab & &quot;Time Changed &quot; & vbtab & &quot;Student/Faculty Affected &quot; & vbtab & &quot;Old Values &quot; & vbtab & &quot;New Values&quot; & vbcrlf & vbcrlf





Do While NOT MyRS.EOF

BodyText = BodyText & Trim(MyRS(&quot;FieldsChanged&quot;)) & &quot; &quot; & vbtab & Trim(MyRS(&quot;DoneByName&quot;)) & vbtab & &quot; &quot; & Trim(MyRS(&quot;UpdatedAt&quot;)) & &quot; &quot; & vbtab & MyRS(&quot;Student_Name&quot;) & vbtab & &quot; &quot; & MyRS(&quot;OldValues&quot;) & &quot; &quot; & vbtab & MyRS(&quot;NewValues&quot;)


MyRS.MoveNext
Loop


That other code was from another version of the file, a file that I have been chopping code from, experimenting with...


Thanks..


Saad
 
I suggest doing your formatting in one instance so you have easier control over it. Try Combining them. Seems like you are doing way too much in the code to get a little out of it. Then you can easily adjust for length. (example) as you get to the thrid column start over on a new line with the fourth column

if not changing it to one var then at least take out some of the vbtab's because I can't see how you could get that all in one line with all the bytes you're taking up. change them to spaces.
rate here
& &quot; &quot; & vbtab
you have 9 bytes give or take that you are placing between the values. why so much space? either get rid of the space or get rid of the tab control
I dare to learn more
admin@onpntwebdesigns.com
 
onpnt, Can you explain more precisely what you mean by &quot;doing your formatting in one instance so you have easier control over it. Try Combining them....Seems like you are doing way too much in the code to get a little out of it. Then you can easily adjust for length. (example) as you get to the thrid column start over on a new line with the fourth column&quot;..

do you mean by &quot;start over on a new line with the fourth column&quot; this:

Code:
BodyText = BodyText & Trim(MyRS(&quot;FieldsChanged&quot;)) & vbtab & Trim(MyRS(&quot;DoneByName&quot;)) & vbtab & Trim(MyRs(&quot;UpdatedAt&quot;))

BodyText = BodyText & Trim(MyRS(&quot;StudentName&quot;)) & .....

that is, changing it from one line of code to two or more lines of code...what effect would this have..other than making the code more readable..

Or do you mean that I should break the output to multiple lines.. instead of the header printing on one line, or a row of data printing on one line...the headers print on multiple lines (i.e. three per line) or the data row prints on multiple lines... If this is what you mean, then all is fine, but won't the output headers lose their allignment with their data columns... or if the data is formatted after the headers, the data would get jumbled up, i mean shouldn't it be one long straight line per row of data instead of half the cells appearing on the first line, and the other half on the second line, and so forth...




Also,

I learnt from


how to send HTML-Formatted email in CDONTS..




I used

Code:
Set myMail = CreateObject(&quot;CDONTS.NewMail&quot;)
myMail.BodyFormat = 0  '0 for HTML-format


But the email goes through as plain text... all the HTML tags get printed out as it is..


Saad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top