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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why Do my Emails Sent from Access/Outlook Not Hold Their Formatting 1

Status
Not open for further replies.

RobertIngles

Technical User
Jan 20, 2011
113
CA
Sending emails from Access. Message body text is taken from a table as it is merged with data specific to the recipient. I cannot get a handle on the message formatting. The formatting I need is not complex, just need page breaks (although I would like to bold, change font etc).

I used "text string1" & Chr(10) & Chr(13) & Chr(10) & Chr(13) &""text string2" (two line breaks). On screen my Access form shows the correct formatting but when I send the email it is just one long string. I tried to use vbCrLf but when I update the table field it appears with quotation marks and Access inserts it as a text string.

I am confused on the field settings in the table design - Plain Text or Rich Text. If I am using & Chr(10) & Chr(13) & should the format be set to rich text or plain? I have tried both and get the same result.

Finally - if I were to create the text with HTML coding, can I use word to create it and then cut and paste to the update field build or do I need to use notepad? The code I am using for the emailing does specify HTML

Can someone please give me some solid answers - I need to be able to use this form for huge distribution lists and need to make it as user friendly as possible.

Private Sub Command20_Click()

Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><H2>"
.To = Me.Email_Address
.Subject = Me.Mess_Subject
.HTMLBody = Me.Message
If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
.Attachments.Add (Me.Mail_Attachment_Path)
End If
'.DeleteAfterSubmit = True 'This would let Outlook send th note without storing it in your sent bin
.Send
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out

Error_out:
End Sub

Thanks everyone!!!!

Thanks
Robert
 
I'd try this:
Code:
...
        With MailOutLook
            .To = Me!Email_Address
            .Subject = Me!Mess_Subject
            .Body = Me!Message
            If Left(Me!Mail_Attachment_Path, 1) <> "<" Then
                .Attachments.Add Me!Mail_Attachment_Path
            End If
            .Send
        End With
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PVH it worked out well. Gonna spend the rest of my evening tryng to figure out how to code it in HTML rather than VBA. If you have any ideas or suggestions on where to start, please let me know!

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top