Link to home
Start Free TrialLog in
Avatar of Seamus2626
Seamus2626Flag for Ireland

asked on

Text over two lines in VBA for email

Hi,

I have some code that is creating a lotus notes email. i want the text in body of the email to split over two lines

"Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report._"
 & "If you have any questions around the content of this report, please contact your regional SPM team in the first instance.

I cant get the syntax right! Can someone amend please?!

Thanks
Avatar of Phillip Burton
Phillip Burton

At the end of the first line, try one of the following
 
& chr(13)
& chr(10)
& chr(13) & chr(10)
Avatar of Seamus2626

ASKER

"Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report" & Chr(13)
"If you have any questions around the content of this report, please contact your regional SPM team in the first instance."


"If you have any questions around the content of this report, please contact your regional SPM team in the first instance."

This is highlighted red now?

Thanks Phillip
You are missing an & after "& chr(13)". You had that at the start of line 2 in your example.
MailDoc.Body = _
"Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report._Chr(13)" &
  & "If you have any questions around the content of this report, please contact your regional SPM team in the first instance"

That is still coming up red Phillip
SOLUTION
Avatar of Phillip Burton
Phillip Burton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
MailDoc.Body = _
 "Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report._Chr(13)" & _
   & "If you have any questions around the content of this report, please contact your regional SPM team in the first instance"


That is returning all red Phillip
please use code tag in comment editor and  post the code again
Thanks

MailDoc.Body = _
 "Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report._Chr(13)" & _
   & "If you have any questions around the content of this report, please contact your regional SPM team in the first instance"

Open in new window

there is 2 & at the end of third line and at the forth line , remove one of them
remove &  in third line
MailDoc.Body = _
 "Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report._Chr(13)" & _
    "If you have any questions around the content of this report, please contact your regional SPM team in the first instance"

Open in new window

Avatar of Thomas Zucker-Scharff
why not use .HTMLBody instead?

For x = CInt(StartRow) To CInt(EndRow)
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
    .To = Worksheets(Name).Cells(x, 1) 'Row x, Column A
    .CC = ""
    .BCC = ""
    .Subject = Worksheets(Name).Cells(x, 3) 'Row x, Column C
    ' greeting using nickname
    .HTMLBody = "Dear " & Worksheets(Name).Cells(x, 18) & "," 'Row x, Column R
    ' first paragraph of letter
    .HTMLBody = .HTMLBody & Worksheets(Name).Cells(x, 8).Value 'Row x, Column H
    ' attach the previous years survey or a blank
    .Attachments.Add Worksheets(Name).Cells(x, 2).Value 'Row x, Column B
    ' attach this years facility usage table or a blank
    .Attachments.Add Worksheets(Name).Cells(x, 17).Value 'Row x, Column Q
    .display
    Application.Wait (Now + TimeValue("0:00:02"))
    Application.SendKeys "%s"
    '.Send
    End With
    Set OutMail = Nothing
Next x

Open in new window


Granted this is code to generate an outlook email, but it can be easily modified.
What HTMLBody? In a Notes mail? No can do.
You can use NotesMimeEntity objects, but then it's a completely different ballgame...
Didn't know that Notes mail didn't use .HTMLBody.  Time to switch to outlook :-)
for me I don't know Lotus Notes at all :)
but very strange that it has VBA!, I thought IBM will never think to do that
Nope, notes has LotusScript, which is similar to VB. In this case, the application is an Excel application that communicates with the Notes client via the COM interface.

@FarWest: time to learn something about Notes :-)
Thanks a lot for the info
But I'm now over 50 and last thing I know about Lotus was 123. 25 years ago
:)
Too old to learn? Well, so am I, maybe... By the way: what's outlook?
Lotus notes is cruel lads, but its what i have to work with!!

So when i put in the below line, it runs over two lines in the editor but still comes out as one line in the body of the email (pic attached)

So i need it to split over two lines in the email so it appears as

Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report.

If you have any questions around the content of this report, please contact your regional SPM team in the first instance

Thanks!

MailDoc.Body = _
 "Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report._Chr(13)" & _
    "If you have any questions around the content of this report, please contact your regional SPM team in the first instance"

Open in new window

Capture.PNG
Try with _Chr(13)_Chr(10)
Sorry Sief, i have no idea where too put _Chr(13)_Chr(10)

I tried

 "Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report._Chr(13)_Chr(10) " & _
    "If you have any questions around the content of this report, please contact your regional SPM team in the first instance"

That's not working though
not inside the string

MailDoc.Body = _
 "Following the communication of 24th February, please find attached the January 2015 version of your personal Horis portfolio Sales Manager report " & vbCRLf &  _
    "If you have any questions around the content of this report, please contact your regional SPM team in the first instance"

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks guys!