roelandwatteeuw
Board Regular
- Joined
- Feb 20, 2015
- Messages
- 87
- Office Version
- 365
- Platform
- Windows
Hi all
What I have:
At this moment I have an Excel with a (working) vba code to generate a mail.
This mail is used as a template. So, same tekst (with some variable data from cells), every time .
What I need:
Now, I want this template mail to be editable by the user.
So I wrote the text in a cell and made vba read out this cell.
Problem:
When the mail is generated, all the 'Enters' are gone.
Simple Code before:
What I've changed:
In sheet 'Admin' I placed the text in cel B64 (making use of 'Alt + Enter' for the next line)
I changed the 'strbody' in the vba-code to:
Result:
The 'Enters' are gone and replaced by 'Spaces'.
I hope there's an easy solution for this problem.
Hope you can help!
Thanks!
R.
What I have:
At this moment I have an Excel with a (working) vba code to generate a mail.
This mail is used as a template. So, same tekst (with some variable data from cells), every time .
What I need:
Now, I want this template mail to be editable by the user.
So I wrote the text in a cell and made vba read out this cell.
Problem:
When the mail is generated, all the 'Enters' are gone.
Simple Code before:
VBA Code:
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<BODY style=font-size:11pt;font-family:Calibri>" & _
Sheets("Admin").Range("C8").Value & _
"<br><br>" & _
"This is an example " & "<br>" & _
"Some text here" & "<br>" & _
"Some more over here" & "<br>" & _
"Ending here:" & "<br>" & _
"<br>" & _
"Please contact me"
On Error Resume Next
With OutMail
.Display
.To = Sheets("Admin").Range("B8").Value
.CC = ""
.BCC = ""
.Subject = "This is the subject"
.HTMLBody = strbody & .HTMLBody
'.Send
End With
What I've changed:
In sheet 'Admin' I placed the text in cel B64 (making use of 'Alt + Enter' for the next line)
I changed the 'strbody' in the vba-code to:
VBA Code:
strbody = "<BODY style=font-size:11pt;font-family:Calibri>" & _
Sheets("Admin").Range("C8").Value & _
"<br><br>" & _
Sheets("Admin").Range("B64").Value
Result:
The 'Enters' are gone and replaced by 'Spaces'.
I hope there's an easy solution for this problem.
Hope you can help!
Thanks!
R.