How do I copy format (Italics / table borders / bold) from excel to outlook via VBA

tarallox

New Member
Joined
May 23, 2015
Messages
7
Hi everyone, Happy New Year!

I've got the following code below however I can't seem to code it to copy and paste the tables / formats (as per header), only words get exported onto email outlook.

Can someone help me to tweek it please? Super appreciate it!

Code in question:

Private Sub CommandButton1_Click()

Dim outl As Object

Dim Mail As Object

Dim myrng As Range

Dim zelle As Range

Dim bodyX$





Set outl = CreateObject("Outlook.Application")

Set Mail = outl.CreateItem(olMailItem)





Set myrng = Sheets("test").Range("text")





Mail.To = Sheets("testF").Range("To")

Mail.CC = Sheets("test").Range("CC")

Mail.BCC = Sheets("test").Range("Bcc")

Mail.Subject = Sheets("test").Range("Subject").Value





For Each zelle In myrng

If Not zelle.Value = "" Then

bodyX = bodyX & zelle.Value & Chr(13)

Else:

bodyX = bodyX & Chr(13)

End If



Next zelle





Mail.Body = bodyX

Mail.Display



End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

The RangetoHTML function copies the range with formatting. See the bottom half of the example for the function

The other option is building up the table as a string using a loop and adding HTML tags as you go round the loop.
Long-winded
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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