Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 store email message body MS SQL 2000

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-30 : 09:44:31
Sriram writes "I am storing the email message of a particular email (body of the
message) in a table. The field in which I am storing this email is of data
type text. Now When I am retreiving the email and displaying it on my ASP
page the format is not displayed as it is displayed in my Outlook. How can I
ensure that the format is stored as it is and displayed vice-versa."

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-05-30 : 11:36:54
I've spent a great deal of time on this in the past and from what I've found is by using a text feild.. you can't do what you want there... SQLmail just isn't very good as far as formatting goes. The only way I've found you can make the format look the same is by creating table as such :

create table emailline(
EmailID int,
LineID int,
emailbody varchar(100)
)
you would then build the email line by line, 100 characters at a time. To display a full email in ASP you would use

select emailbody from emailline where emailid = 1 order by lineID

In asp you would load a recordset with this and use a while loop to print the RS until the rs is empty
while not rs.eof
--Little bit of html code to make it look nice
rs.emailbody
wend

In the actual SQL for the send mail I used a cursor to build a variable with each line (i'd seperate lines by +char(13)+)
so @msg = @msg + @emailbody + char(13)

that would ensure the enters were in the smae place. Last thing to do is get the varchar(100) that the emailbody column is declared as to a interval that is exactly 1 or 2 lines in an email. Little bit of a long way around it... But it's worked in the past

Go to Top of Page
   

- Advertisement -