Display wrapped cell into outlook E-mail

Rugz

New Member
Joined
Apr 12, 2022
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
I can't find the answer anywhere. I have an automated E-mail template. In one of my cells there is text that is wrapped. I want it to display that way in my E-mail.
This is my current code. Its cell C4 I want displayed properly.


Sub Email1()
' Working in Office 2000-2016
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

strbody = "Hello,<BR><BR>" & _
"We are currently below our MAX for the following part. Please send over a quote no later than<b> " & [E2] & " </b>with a cost and lead time.<br><br>" & _
"<b>Requesting QTY#: " & [H4] & " " & [I4] & " for Part #: " & [G4] & "</b><br>" & _
"<b>Please provide a quantity discount if available</b><br><br>" & _
"<b>" & [C4] & "</b><br><br>"

On Error Resume Next
With OutMail
.display
.To = [A4]
.Subject = [G4] & " Request"
.HTMLBody = strbody & "<br>" & .HTMLBody
End With

On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Rows("4").Interior.Color = 65535
End Sub



This is the output

1649817670470.png


In the cell it looks like this:

Generic text
Displays a Manufacture Name
Displays a Manufacture part
More text



Please help!
Very appreciated!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

KOKOSEK

Well-known Member
Joined
Apr 8, 2019
Messages
508
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
What if instead of [C4] in your code you will put:

VBA Code:
Replace([C4], Chr(10), "<br>")
 
Solution

Rugz

New Member
Joined
Apr 12, 2022
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
What if instead of [C4] in your code you will put:

VBA Code:
Replace([C4], Chr(10), "<br>")
You just solved my issue!! I was banging my head against a wall trying to figure this out! I'm not a coder so I really appreciate the help. I'm learning all this stuff through google searches. Again, I really appreciate the help!
 

Forum statistics

Threads
1,186,126
Messages
5,956,050
Members
438,231
Latest member
fuzdrum

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
Top