Can somebody help me test my VBA code and fix it if it does not work?

Jyggalag

Active Member
Joined
Mar 8, 2021
Messages
445
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi all,

I have this VBA code to write an email body text:

eBody = "Dear person," & "<BR><BR>"
eBody = eBody & " 1Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text (Text text Text text Text text "quote") Text text Text text Text text Text text Text text Text text Text text. " & "<BR><BR>"
eBody = eBody & " 2Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text. " & "<BR><BR>"
eBody = eBody & " 3Text text, """ & "<b><u>" ", Text text Text text Text text Text text Text text Text text Text text Text text" & "</b></u>" & " ""Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text. " & "<BR><BR>"
eBody = eBody & " 4Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text """ & "<b><u>" "Text text Text text Text text Text text Text text Text text" & "</b></u>" & " ""Text text Text text Text text Text text Text text. " & "<BR><BR>"
eBody = eBody & " 5Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text.. " & "<BR><BR>"
eBody = eBody & " 6Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text. """ & "<b>" "Text text Text text Text text Text text Text text Text text." & "</b>" & " ""Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text:" & "<BR><BR>"
eBody = eBody & "<b>" & "-" & "</b>"
eBody = eBody & "Text1text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1" & "<BR>"
eBody = eBody & "<b>" & "-" & "</b>"
eBody = eBody & "Text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2" & "<BR>"
eBody = eBody & "<b>" & "-" & "</b>"
eBody = eBody & "Text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3" & "<BR>"
eBody = eBody & "<b>" & "-" & "</b>"
eBody = eBody & "Text4 Text4 Text4 Text4 Text4 Text4 Text4 Text4""" & "<b><u>" "Text4 Text4 Text4 Text4 Text4 Text4 Text4" & "</b></u>" & "". "" & "<BR><BR>"
eBody = eBody & "Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text """ & "<u>" "TextText TextTextTextTextTextText." & "</u>" & " ""." & "<BR><BR>"
eBody = eBody & "Kind regards," & "<BR><BR>"

I want it to come out looking like this when it is inserted into an email (screenshot from word):

1642519976642.png


Can somebody please take a look at my code, maybe run it if possible, and tell me if the email formatting is on point? And if not, can you please assist me in fixing whatever formatting errors might be there?

I am having some difficulty running itself myself at the moment and I am really worried about the text written in bold with an underline (b and u) and whether it has been coded correctly.

I would appreciate some assistance a lot!

Thank you everybody :)

Kind regards,
Jyggalag.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Here is a working eBody, now you create an Email and see if you need some other fixing.
Code:
ebody = "<!DOCTYPE HTML PUBLIC              '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd' >"
ebody = ebody & "<html xmlns=               'http://www.w3.org/1999/xhtml'>"
ebody = ebody & "<body>"
ebody = "Dear person," & "<BR><BR>"
ebody = ebody & " 1Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text (Text text Text text Text text ""quote"") Text text Text text Text text Text text Text text Text text Text text. " & "<BR><BR>"
ebody = ebody & " 2Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text. " & "<BR><BR>"
ebody = ebody & " 3Text text, """ & "<b><u>" & ", Text text Text text Text text Text text Text text Text text Text text Text text" & "</b></u>" & " ""Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text. " & "<BR><BR>"
ebody = ebody & " 4Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text """ & "<b><u>" & "Text text Text text Text text Text text Text text Text text" & "</b></u>" & " ""Text text Text text Text text Text text Text text. " & "<BR><BR>"
ebody = ebody & " 5Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text.. " & "<BR><BR>"
ebody = ebody & " 6Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text. """ & "<b>" & "Text text Text text Text text Text text Text text Text text." & "</b>" & " ""Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text Text text:" & "<BR><BR>"
ebody = ebody & "<b>" & "-" & "</b>"
ebody = ebody & "Text1text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1 text1" & "<BR>"
ebody = ebody & "<b>" & "-" & "</b>"
ebody = ebody & "Text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2" & "<BR>"
ebody = ebody & "<b>" & "-" & "</b>"
ebody = ebody & "Text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3 text3" & "<BR>"
ebody = ebody & "<b>" & "-" & "</b>"
ebody = ebody & "Text4 Text4 Text4 Text4 Text4 Text4 Text4 Text4" & "<b><u>" & "Text4 Text4 Text4 Text4 Text4 Text4 Text4" & "</b></u>" & ". " & "<BR><BR>"
ebody = ebody & "Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text " & "<u>" & "TextText TextTextTextTextTextText." & "</u>" & " ""." & "<BR><BR>"
ebody = ebody & "Kind regards," & "<BR><BR>"
ebody = ebody & "</body>"
ebody = ebody & "</html>"
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top