Microsoft Access
--
Questions
--
Followers
Top Experts
"Line1" & vbCrLf & _
"Line2" & vbCrLf & _
vbCrLf & vbCrLf & vbCrLf & _
"We respect your privacy. " & vbCrLf
That is then put with some other text. It works and the output in the email is neatly formatted as:
Line1
Line2
West respect your privacy.
However when that email is replied to that same text is reformatted as:
Line1 Line2
West respect your privacy.
Is it possible to prevent this and keep my line breaks in a replied email? (Using Outlook 2003) I'm thinking that Outlook is removing extra spaces?
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I know that's happened to me in the past, you send a nicely formatted message and it comes back as part of the reply in a bit of a jumble.
Tom






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Instead of .Body = "some strings"
you'd have
.BodyFormat = olFormatHTML
.HTMLBody = "Line1" & "<br>"
.HTMLBody =.HTMLBody & "Line2" & "<br>"
.HTMLBody =.HTMLBody & "<br><br><br>We respect your privacy.<br>"
If Outlook is the formatting villain, this may get you around it
(When I do code like this I use an Outlook reference, and can therfore use the constant olFormatHTML. I am not sure what number it represents, if you are using late-binding)

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I have Outlook (set to send/read in HTML) and the reply looks fine.
(Line breaks look the same as in the reply as in the original email)
This may be an issue with the recipients email settings.
In which case there may not be that much you can do, ..short of *forcing* them to change their settings...
...You can go all out and create the email via Automation (then try using .HTMLBody and using <br> instead of vbcrlf...) but even this may not work, and seems like overkill...
JeffCoachman
What you pasted does not look like valid SMTP text. But if those are indeed the actual characters in the SMTP text (which seems unlikely), then what characters are you using for carriage-return (CR) and line-feed (LF)? CR should be 7-bit ASCII code 13, and LF should be 7-bit ASCII code 10.
Note that the physical text of a SMTP e-mail is not HTML nor RTF nor anything other than quoted-printable 7-bit ASCII. So, the actual text portion is needed rather than any HTML or RTF or other embedded attachment such as is created for HTML mail for example.
Tom
vbCrLf is Chr(13) & Char(10).
If you try Len(vbCrLf) in VBA it returns 2.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
True, but that is not what the actual text of the e-mail will be. The definition of the issue will involve the physical text of an e-mail item, not any program/script statements that create an e-mail.
In order to have an idea about what some (possibly unknown) e-mail client is going to do with an item, it is necessary to know what is actually received by clients. From there, it can be worked backwards to code that generates and to probable changes that will generate more predictable e-mail.
If an e-mail item is saved as a file and then opened with, e.g., Notepad, the actual item will be seen. That's what should illuminate probable causes of strange or undesired behaviors.
Tom
But I don't think that there is much else that VBA/Access can do with either of these two methods to muck with formatting. The vagarities of the receiving client cannot likely be overcome.
DoCmd.SendObject , , , Me.Email, , , sSubject, sBody
As far as I can tell I can not use any sort of HTML code with SendOjbect. I think the sort answer to my question is its not possible.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
SendObject is pretty rudimentary.
Automating Outlook does have some benefits as well as the one security prompt drawback.
For one, the resulting email winds up in Sent Items which can be nice for traceablity.
But now, from the Access 2003 help
The SendObject method carries out the SendObject action in Visual Basic.
expression.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)
expression Required. An expression that returns one of the objects in the Applies To list.
ObjectType Optional AcSendObjectType.
AcSendObjectType can be one of these AcSendObjectType constants.
acSendDataAccessPage
acSendForm
acSendModule
acSendNoObject default
acSendQuery
acSendReport
acSendTable
ObjectName Optional Variant. A string expression that's the valid name of an object of the type selected by the objecttype argument. If you want to include the active object in the mail message, specify the object's type with the objecttype argument and leave this argument blank. If you leave both the objecttype and objectname arguments blank (the default constant, acSendNoObject, is assumed for the objecttype argument), Microsoft Access sends a message to the electronic mail application without an included database object. If you run Visual Basic code containing the SendObject method in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.
OutputFormat Optional Variant.
To Optional Variant. A string expression that lists the recipients whose names you want to put on the To line in the mail message. Separate the recipient names you specify in this argument and in the cc and bcc arguments with a semicolon (;) or with the list separator set on the Number tab of the Regional Settings Properties dialog box in Windows Control Panel. If the recipient names aren't recognized by the mail application, the message isn't sent and an error occurs. If you leave this argument blank, Microsoft Access prompts you for the recipients.
Cc Optional Variant. A string expression that lists the recipients whose names you want to put on the Cc line in the mail message. If you leave this argument blank, the Cc line in the mail message is blank.
Bcc Optional Variant. A string expression that lists the recipients whose names you want to put on the Bcc line in the mail message. If you leave this argument blank, the Bcc line in the mail message is blank.
Subject Optional Variant. A string expression containing the text you want to put on the Subject line in the mail message. If you leave this argument blank, the Subject line in the mail message is blank.
MessageText Optional Variant. A string expression containing the text you want to include in the body of the mail message, after the object. If you leave this argument blank, the object is all that's included in the body of the mail message.
EditMessage Optional Variant. Use True (–1) to open the electronic mail application immediately with the message loaded, so the message can be edited. Use False (0) to send the message without editing it. If you leave this argument blank, the default (True) is assumed.
TemplateFile Optional Variant. A string expression that's the full name, including the path, of the file you want to use as a template for an HTML file.
EditMessage and TemplateFile would seem to imply that you can use HTML, and that you can have the message open before actually sending it.
If you do so, what does it look like?
Microsoft Access
--
Questions
--
Followers
Top Experts
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.