RobertIngles
Technical User
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 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