Solved

Access, HTML email, memo fields and new lines/carriage returns

Posted on 2012-03-15
3
541 Views
Last Modified: 2012-03-15
Hello;

I've built a function in our access database that generates an HTML email and populates some of the body of the email from a few different records in the database.  (So I've essentially wrapped HTML within access code by setting .HTMLBody = "htmlCodeHere").

I used to send this email out using SendObject format TXT, now writing this to create a pretty HTML email.

It works great, with one exception:  I have a memo field in the database where users enter data: some times sentences, some time paragraphs, always with several carriage returns/new lines.  The problem: HTML doesn't interpret these as enters/new lines when formulating the email.  

Example, if the memo field has the following data:

* line one here
* line two here
* line three here

It will output in the email as:

* line one here * line two here * line three here.

Obviously the HTML tag for new line is <br>, but how do I get the database or HTML to interpret the new lines in the memo field into a new line in the HTML code?

Thanks all.
0
Comment
Question by:Uptime Legal Systems
  • 2
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 37725499
Not sure how you are getting your memofield out of your database, but assuming that you have read it into a string variable, you could try replacing the carriage returns with <br> tags to formulate your html message:


strHTMLMessage = Replace(strYourMemoField, vbCRLF, "<br>")
0
 
LVL 6

Author Comment

by:Uptime Legal Systems
ID: 37725533
Yes, I read it into a String.  Essentially:

strBody = me.Body
.htmlBody = strBody

So would I replace this with:

strBody = me.Body
.htmlBody = Replace(strBody),vbCRLF,"<br>")

?
0
 
LVL 6

Author Comment

by:Uptime Legal Systems
ID: 37725561
That worked--thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now