Email from Access 2007

G

Guest

Hi - i have searched and searched and put together this bit of code. It
works fine but however i structure it (and believe me i've tried different
ways) i can't get the body of the email formatted with the line breaks i
need. It all comes out in one string! I did just put it in as a string with
vbCrLf in and also trying chr(10) etc but to no avail!

Please help!

Dim EmailAddress As String
EmailAddress = Me!email

Dim olApp As Outlook.Application
Dim objMail As MailItem
Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
Dim bod As String
Dim fso As FileSystemObject
Dim strbody As TextStream

Set fso = New FileSystemObject
Set strbody = fso.OpenTextFile("C:\Documents and Settings\Helsi\My
Documents\Cambridge - PWL\welcome.txt", ForReading)
bod = strbody.ReadAll
strbody.Close

With objMail
.BodyFormat = olFormatHTML
.HTMLBody = bod
.Display
.To = EmailAddress
.Subject = "Welcome To Cambridge"

End With
 
P

Paul Shapiro

You're sending HTML format. CrLf works in plain text. In html you have to
use <BR>. Try bod =Replace(bod, vbCrLf, "<BR>" & vbCrLf). That still leaves
in the CrLf so the format would be legible in plain text, but adds the html
command for a new line.
Paul Shapiro
 
G

Guest

Thank you so much! I've been working on this for 2 days!!!

Just to save me another 2 days - how do i save the email address in that
code to the outlook address book automatically?

Many thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top