-
Issue VBA Copying/Displaying Table in Email Body
Hi everyone,
I have a very limited VBA knowledge and have been struggling with the following;
Everyday I'm sending different data by email and found a way thanks to VBA to automate the process, when I get to the "creation email step", I have some issues apparently because of the format (not in HTML), displaying the email addresses and text in the body is fine as it is all linked to specific cells however if I want to display a table (within a specific range) it does not work
My current code is the following;
Sub George()
Dim a As Integer
Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As Range
Dim rngCc As Range
Dim rngSubject As Range
Dim rngBody As Range
Dim rngAttach As Range
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
a = ActiveCell.Row
With ActiveSheet
Set rngTo = .Cells(22, "B")
Set rngCc = .Cells(24, "B")
Set rngSubject = .Cells(26, "B")
Set rngBody = .Range("B28")
'Set rngAttach = .Range("B4")
End With
With objMail
.To = rngTo.Value
.CC = rngCc.Value
.Subject = rngSubject.Value
.Body = rngBody.Value
'.Attachments.Add rngAttach.Value
.Display 'Instead of .Display, you can use .Send to send the email _
or .Save to save a copy in the drafts folder
End With
Set objOutlook = Nothing
Set objMail = Nothing
Set rngTo = Nothing
Set rngSubject = Nothing
Set rngBody = Nothing
Set rngAttach = Nothing
End Sub
To recap my query is: "how to display a specific range as an email body from excel ?"
Apologies if I'm in the wrong section of the forum or if it has already been discussed, I tried to solve this by visiting other places and reading people with the same issue but couldn't solve it
Thank you very much
Regards
DidierIV
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules