vbNewLine use at Email body

Leo_Polla_Psemata

Registered User.
Local time
Today, 07:01
Joined
Mar 24, 2014
Messages
364
Hi
I use docmd.send object method to send emails.
In the body of the email there is some text, i feed new line with vbNewLine
I see the email body just perfect, for example

Dear Client,
Please find below our contract number "a"
It is related to your request on 1st of August
Then I checked the recipient email which was like this
Dear Client,Please find below our contract number "a"It is related to your request on 1st of August and the whole email continues ...
Why i see my email just perfect and at the other end, receiver does not see the same?
Is there any work around to it ?
 
SBody = "this is my" & vbCrLf
SBody = "and this is line," & vbCrLf
 
Yes,
This is the way i do it
SBody = "Dear Client," & vbCrLf &"Please find below our contract number 'A' ," & vbCrLf & " This is .... "


I see in my screen after I run the docmd.sendobject ,
~~~
Dear Client,
Please find below our contract number "a"
It is related to your request on 1st of August
~~~
recipient is my colleague next to me,
I click "send" from outlook

Then
I go to my colleague screen, i see that there are no line breaks
The email looks like this, all in one line

Dear Client,Please find below our contract number "a"It is related to your request on 1st of August and the whole email continues ...
 
I tried this sending the line to myself and I received it with the new line. I'm using Microsoft Outlook and Windows 7. What is your colleague using? Is it a MAC?

You might have to send you email in HTML format using OutLook Automation.
 
I have never seen that before using an e-mail system based on SMTP. In a "pure" Windows environment in which the sender is Win 7 and SMTP to an SMTP relay to cross networks to an Exchange server to MS Outlook as the final recipient, my use of vbCrLf works as a true line break even where the Outlook is set to convert all received messages as "pure text."

I am thinking that the recipient's system must be UNIX-based. Before we go crazy here, could you verify that you are, indeed, looking at a Windows-to-non-Windows mail transfer? Otherwise we will be barking up the wrong tree.

If your recipient is UNIX-based, it might something so simple as to use a different line break method besides vbCrLf. If not, then we need to know about the mail receiver s/w on your colleague's machine.
 
Hi
Thanks for the input.
We both have windows, same systems.

It is not only this example I put here.
Sometimes, I send emails to clients, real emails, they reply to me
and I see that they have received my email without line breaks.


ps
I am very keen on using the docmd.sendobject method, it helps me to customize and uniform some routine emails, transfer always the correct data without copy paste/typing and clerical errors.
 

Hi, yiap, right ,
this is it,
it is an option in outlook.
If we ask from recipient to

For Outlook 2010 and later versions:

  1. Open Outlook.
  2. On the File tab, click Options.
  3. In the Options dialog, click Mail.
  4. In the Message format section, clear the Remove extra line breaks in plain text messages check box.
  5. Click OK.



Then the recipient receives the proper email format.

Of course we cannot ask from every client to change his option which he may doesn't even know, we should send in HTML format , docmd.send option method does not support it
I don't know if we can make any bit of code and change format in HTML or if there is any option through outlook.
 
Does it always be in the same format (font size/color) or does it change depending of the values in the fields/controls?
Could you show a printscreen of what you want?
 
You would have to change your routine to use Outlook Automation to send in HTML.
It is more involved that the sendobject method but there are many advantages in it's flexibility.
There are numerous examples on here including a complete module.

This is a basic routine to give you an idea
Code:
Dim OutApp As Object
    Dim OutMail As Object
    Dim sSignature As String
    '-- Standard Email Variables
    Dim Variable_To As String
    Dim Variable_Subject As String
    Dim Variable_Body As String
    Dim Variable_AttachmentFile As String

    Variable_To = "Someone@Somwhere.com"
    Variable_Subject = "My Email about something"

    Variable_Body = "<style> " & _
     "p {font-size:11pt; font-family:Calibri}" & _
     "</style>" & _
     "<p>" & "Good Morning " & Me.ContactFirstName & "," & "</p>" & _
     "<p>" & "" & "</p>" & _
     "<p>" & "Your data goes in here: " & Me.Data1 & "<br/>" & _
     "More Text goes here : " & Me.SecondDatafield & "</p>"

  Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail       [COLOR="green"] ' This creates a blank email and captures the users default signature.[/COLOR]
        .BodyFormat = olFormatHTML
        .Display
    End With
    
    sSignature = OutMail.HTMLBody
        
    With OutMail
    
        .To = Variable_To
        .CC = ""
        .BCC = ""
        .Subject = Variable_Subject
        '.Attachments.Add (Variable_AttachmentFile)
        .HTMLBody = Variable_Body & sSignature
        .Display  [COLOR="Green"] 'or use .Send[/COLOR]
        .ReadReceiptRequested = False
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
__________________
 
what if you try not using the LF linefeed? try

SBody = "Dear Client," & vbCr &"Please find below our contract number 'A' ," & vbCr & " This is ....

or lose the CR carriage return?
 

Users who are viewing this thread

Back
Top Bottom