VBA Function to remove line spaces in an Email

Ragham26

New Member
Joined
Sep 17, 2024
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hi,

I have compiled a macro for sending an outlook email using instruction from various sources on the internet. I have little to no experience writing VBA code and cannot find out how to do the last thing I need. As the macro is rather large I have only shown below the part I need help with.


emailItem.HTMLBody = "Hi,<p>" & vbNewLine & vbNewLine & "Please find attached, the Weekly Error Log.<p>" & _
vbNewLine & vbNewLine & _
"Please respond where necessary as soon as possible.<p>" & _
vbNewLine & vbNewLine & _
"<i>Unfortunately, there may be instances where items still appear on the error log<p>"_
& vbNewLine & "that have already been responded to. Whilst every endeavour will be made<p>"_
& vbNewLine & "to check for replies before it's sent out, there may be some that slip through the net.<p>" _
& vbNewLine & "These will not, however, appear on the next error log.<\i> <p>"_
& vbNewLine & vbNewLine & "Kind Regards<p>" & vbNewLine & "Retail Accounts Team"


I would like to remove the line spaces between the text I have highlighted in bold and wondered if there was an easy way to do this. Any help would be greatly appreciated.
The way the text appears in the body of the Email when the macro is run is shown below:



Hi,

Please find attached, the Weekly Error Log.

Please respond where necessary as soon as possible.


Unfortunately, there may be instances where items still appear on the error log

that have already been responded to. Whilst every endeavour will be made

to check for replies before it's sent out, there may be some that slip through the net.

These will not, however, appear on the next error log.



Kind Regards

Retail Accounts Team
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Welcome to MrExcel.

Use <br> for the new row:

Rich (BB code):
    emailItem.HTMLBody = "Hi,<br><br>" & "Please find attached, the Weekly Error Log.<br>" & _
      "Please respond where necessary as soon as possible.<br>" & _
      "<i>Unfortunately, there may be instances where items still appear on the error log" _
      & "that have already been responded to. Whilst every endeavour will be made" _
      & "to check for replies before it's sent out, there may be some that slip through the net." _
      & "These will not, however, appear on the next error log.</i><br><br>" _
      & "Kind Regards<br>" & "Retail Accounts Team"

Ex:
1726600562648.png



🤗
 
Upvote 0
Solution

Forum statistics

Threads
1,224,811
Messages
6,181,081
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