string problem with vbCrLf

User avatar
sal21
PlatinumLounger
Posts: 3567
Joined: 26 Apr 2010, 17:36

string problem with vbCrLf

Post by sal21 »

Code: Select all

....
 Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        
        'OutMail.Display
        
        BODY = T1 & vbCrLf & vbCrLf & T2 & vbCrLf & vbCrLf & T3 & vbCrLf & vbCrLf & T4 & vbCrLf & vbCrLf & T5 & vbCrLf & vbCrLf & T6 & vbCrLf & vbCrLf & T7 & vbCrLf & vbCrLf & T8 & vbCrLf & vbCrLf & T9 & vbCrLf & vbCrLf & T10 & vbCrLf & vbCrLf & T11 & vbCrLf & vbCrLf & T12 & vbCrLf & vbCrLf & T13 & vbCrLf & vbCrLf & T14 & vbCrLf & vbCrLf & T15 & vbCrLf & vbCrLf & T16 & vbCrLf & vbCrLf & T17 & vbCrLf & vbCrLf & T18 & vbCrLf & vbCrLf & T19 & vbCrLf & vbCrLf & T20 & vbCrLf & vbCrLf & T21 & vbCrLf & vbCrLf & T22 & vbCrLf & vbCrLf & T23 & vbCrLf & vbCrLf & T24 & vbCrLf & T25 & vbCrLf & vbCrLf & T26 & vbCrLf & T27 & vbCrLf & vbCrLf & T28 & vbCrLf & vbCrLf & T29
        
        With OutMail
            .Display
            .To = AAA@iol.it"
            .CC = "BBB@gmail.com;" & D1
            .BCC = ""
            .Subject = "CLI"
            
            .Attachments.Add "C:\A_TL_IMAGE\NOTA.jpg"
            
            sImgName = "NOTA.jpg"
            .HTMLBody = "<img src='cid:" & sImgName & "'" & " ><br>" & vbCrLf & vbCrLf & BODY
            
             End With
        
        Set OutMail = Nothing
        Set OutApp = Nothing
            ....
            
Why yhe BODY string dont accept the vbCrLf , all is writing in body of email in one line!

i need to paste BODY to the bottom of image

note:
body as string

User avatar
HansV
Administrator
Posts: 71216
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: string problem with vbCrLf

Post by HansV »

This is because you are using the HTMLBody property of the OutMail object. Use the Body property instead.
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 3567
Joined: 26 Apr 2010, 17:36

Re: string problem with vbCrLf

Post by sal21 »

HansV wrote:
24 Apr 2021, 17:33
This is because you are using the HTMLBody property of the OutMail object. Use the Body property instead.
....
sImgName = "NOTA.jpg"
.HTMLBody = "<img src='cid:" & sImgName & "'" & " ><br>" & vbCrLf & vbCrLf
.Body = BODY
...
????

User avatar
HansV
Administrator
Posts: 71216
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: string problem with vbCrLf

Post by HansV »

If you want to use HTMLBody, do NOT use vbCrLF! It is not valid in HTML. Use "<p>" instead of vbCrLf.

Code: Select all

        BODY = T1 & "<p>" & "<p>" & T2 & "<p>" & "<p>" & T3 & "<p>" & "<p>" & T4 & "<p>" & "<p>" & T5 & "<p>" & "<p>" & T6 & "<p>" & "<p>" & T7 & "<p>" & "<p>" & T8 & "<p>" & "<p>" & T9 & "<p>" & "<p>" & T10 & "<p>" & "<p>" & T11 & "<p>" & "<p>" & T12 & "<p>" & "<p>" & T13 & "<p>" & "<p>" & T14 & "<p>" & "<p>" & T15 & "<p>" & "<p>" & T16 & "<p>" & "<p>" & T17 & "<p>" & "<p>" & T18 & "<p>" & "<p>" & T19 & "<p>" & "<p>" & T20 & "<p>" & "<p>" & T21 & "<p>" & "<p>" & T22 & "<p>" & "<p>" & T23 & "<p>" & "<p>" & T24 & "<p>" & T25 & "<p>" & "<p>" & T26 & "<p>" & T27 & "<p>" & "<p>" & T28 & "<p>" & "<p>" & T29

        ...

            .HTMLBody = "<img src='cid:" & sImgName & "'" & " ><br>" & "<p>" & "<p>" & BODY
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 3567
Joined: 26 Apr 2010, 17:36

Re: string problem with vbCrLf

Post by sal21 »

HansV wrote:
24 Apr 2021, 18:16
If you want to use HTMLBody, do NOT use vbCrLF! It is not valid in HTML. Use "<p>" instead of vbCrLf.

Code: Select all

        BODY = T1 & "<p>" & "<p>" & T2 & "<p>" & "<p>" & T3 & "<p>" & "<p>" & T4 & "<p>" & "<p>" & T5 & "<p>" & "<p>" & T6 & "<p>" & "<p>" & T7 & "<p>" & "<p>" & T8 & "<p>" & "<p>" & T9 & "<p>" & "<p>" & T10 & "<p>" & "<p>" & T11 & "<p>" & "<p>" & T12 & "<p>" & "<p>" & T13 & "<p>" & "<p>" & T14 & "<p>" & "<p>" & T15 & "<p>" & "<p>" & T16 & "<p>" & "<p>" & T17 & "<p>" & "<p>" & T18 & "<p>" & "<p>" & T19 & "<p>" & "<p>" & T20 & "<p>" & "<p>" & T21 & "<p>" & "<p>" & T22 & "<p>" & "<p>" & T23 & "<p>" & "<p>" & T24 & "<p>" & T25 & "<p>" & "<p>" & T26 & "<p>" & T27 & "<p>" & "<p>" & T28 & "<p>" & "<p>" & T29

        ...

            .HTMLBody = "<img src='cid:" & sImgName & "'" & " ><br>" & "<p>" & "<p>" & BODY
Bravo!
Work fine, now!