473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

String Variable not formatted in HTML Email

30
Hi Guys,

Been racking my brain most of the afternoon on this one, if anyone can shed any light, i would really appriciate it.

Basically I am pulling the body of an email out as text not HTML into a variable called Description (string), if i show the variable in a msgbox it is formatted in terms of line breaks etc.

I then add the description variable to a line in an HTML formatted email, the email is perfect except the Description variable which has no line breaks etc, so it all appears on one line.

Any thoughts?

Here's the HTML code:
Expand|Select|Wrap|Line Numbers
  1. mail.IsBodyHtml = True
  2. mail.Body = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""> " &
  3. "<html xmlns=""http://www.w3.org/1999/xhtml"">" &
  4. "<head>" &
  5. "<style type=""text/css"">" &
  6. "body {background-color:ffffff;background-image:url(http://);background-repeat:no-repeat;background-position:top left;background-attachment:fixed;text-align:left;font-family:Garamond;font-size:14px;font-style:normal;font-weight:550;color:000000;}" &
  7. "</style>" &
  8. "</head> " &
  9. "<body>" &
  10. "<p>--------------------------------------------------------------</p>" &
  11. "<p></p>" &
  12. description &
  13. "<p></p>" &
  14. "<p>--------------------------------------------------------------</p>" &
  15. "</body>" &
  16. "</html>"
Dec 4 '12 #1
3 2301
Frinavale
9,735 Expert Mod 8TB
I'm not entirely sure what you're having problems with by try this.


Expand|Select|Wrap|Line Numbers
  1. mail.IsBodyHtml = True
  2.  
  3. Dim theBody As New Text.StringBuilder
  4.  
  5. theBody.AppendLine("<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""> ")
  6. theBody.AppendLine("<html xmlns=""http://www.w3.org/1999/xhtml"">")
  7. theBody.AppendLine("<head>")
  8. theBody.AppendLine("<style type=""text/css"">")
  9. theBody.AppendLine("body {background-color:ffffff;background-image:url(http://);background-repeat:no-repeat;background-position:top left;background-attachment:fixed;text-align:left;font-family:Garamond;font-size:14px;font-style:normal;font-weight:550;color:000000;}")
  10. theBody.AppendLine("</style>")
  11. theBody.AppendLine("</head> ")
  12. theBody.AppendLine("<body>")
  13. theBody.AppendLine(<p>--------------------------------------------------------------</p>")
  14. theBody.AppendLine("<p></p>")
  15. theBody.AppendLine(description)
  16. theBody.AppendLine("<p></p>")
  17. theBody.AppendLine("<p>--------------------------------------------------------------</p>")
  18. theBody.AppendLine("</body>")
  19. theBody.AppendLine("</html>")
  20.  
  21.  
  22. mail.Body = theBody.ToString
Edit:
I just re-read your question.
You need to post the code populates the description variable. Did you put line breaks in it?


-Frinny
Dec 4 '12 #2
Asprisa
30
Hi Frinny,

Thanks for the reply, I was doing some thinking last night and managed to come up with the answer this morning.

It goes along the lines you were thinking at the bottom of your post:

Expand|Select|Wrap|Line Numbers
  1. theBody.AppendLine("<p>")
  2.  
  3. Using SR = New IO.StringReader(description)
  4.  
  5. While SR.Peek >= 0
  6.  
  7. Dim l As String = SR.ReadLine()
  8.  
  9. theBody.AppendLine(l & "<br />")
  10.  
  11. End While
  12.  
  13. End Using
  14.  
  15. theBody.AppendLine("</p>")
  16.  
  17.  
This code was able to strip each line out of the string, and then i simply put the HTML formatting around the output.

Thanks for your help!

James.
Dec 5 '12 #3
Frinavale
9,735 Expert Mod 8TB
I'm glad you solved the problem :)

-Frinny
Dec 5 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Craig Thomson | last post by:
Do people generally try and output nicely formatted html from their scripts? I have been trying to, with variable indenting for tables etc. It makes it easier to see the html and perhaps debug...
5
by: Ian N | last post by:
Hi, I'm creating a site that posts orders to an email address when they're submitted, these orders need to be in the form of official invoices so i'm using HTML to format them. I already have...
2
by: Himaxda0 | last post by:
Is it possible to access Objects like (document.form1.textfield1) with a string variable like (var obName='textfield1') and using (document.form1.obName.value)? Ive tried it in IE but the value in...
4
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
4
by: weirdstuff | last post by:
Hi. I have this simple code: =========================================== ->Database query here (.. some code) $row=mysql_fetch_array($res); (...)
3
by: shawrie | last post by:
Hello everyone can anyone please help me? I basically want to set the length of a string variable to help spacing my simple report out. i tried dim test as string(14) but it didnt like that
4
by: cybervigilante | last post by:
I sent HTML formatted email, using PHP, to my Yahoo address from my server, and it came out fine, styles and all. I sent it to my gmail address to test it and all I see is the raw html code. But I...
0
by: mrajeshbabu | last post by:
hi this is Rajesh i am working with email concept in asp.net 2.0 i am using html formatted email and i have put in table control all the images and text
2
by: Artie | last post by:
Hi, I've searched the web but can't find a solution to an apparently really simple problem. My app contains an HTML string and I need to be able to invoke the Print Dialog to print the HTML...
2
by: rickyeager | last post by:
ADezii - I found this info very interesting. I have been trying to find a way to send formatted emails to customers after certain events occur from my MS Access database. I have not found any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.