I have a VBA that copies the details from an excel sheet to a outlook mail body: Below is the macro:
Sub Send_Email() Dim EmailSubject As String Dim SendTo As String Dim EmailBody As String Dim ccTo As String EmailSubject = "Test" SendTo = "email@example.com" FirstRow = 1 LastRow = 5 FirstCol = 1 LastCol = 2 For r = FirstRow To LastRow For c = FirstCol To LastCol For Each cell In Cells(r, c) strtable = strtable & " " & cell.Value Next Next strtable = strtable & vbNewLine Next EmailBody = "Hi" & vbLf & vbLf & " body" & vbLf & vbLf & strtable & vbNewLine Set App = CreateObject("Outlook.Application") Set Itm = App.CreateItem(0) With Itm .Subject = EmailSubject .To = SendTo .CC = ccTo .Body = EmailBody .Display '.Send End With Set App = Nothing Set Itm = Nothing End Sub
But the details on the excel sheet are in a tabular format, with some formatting. Can the table and formatting be retained, when data is copied into outlook? If Yes, how?