Loop - Add Excel File as an Attachment and also Paste in Email Body in outlook

jenitak87

New Member
Joined
Aug 25, 2021
Messages
2
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a basic macro, where different files can be attached to send a mail

Where i am stuck is , if there is a possibility to copy that excel in E-mail body as well

Can you help tweak below Code, My destination path is in path_ = cell.Offset(1, 8).Value

The attachment only has table , the path is in the last columns,

Based on the path how can I attached as well as copy the range and paste in the EMAIL body

1629884241667.png



Sub SendEmail()
Dim OutlookApp As Object
Dim MItem As Object
Dim cell As Range
Dim email_ As String
Dim email2_ As String
Dim cc As String
Dim subject_ As String
Dim body_ As String
Dim path_ As String
Dim intX As String
Dim intY As String
Dim intZ As String
Dim Body
Set mainWB = ActiveWorkbook



Sheets("Duplicates").Select
Range("A1").Select

'Create Outlook object
Set OutlookApp = CreateObject("Outlook.Application")

' Loop through the rows
For Each cell In Columns("a").Cells.SpecialCells(xlCellTypeConstants)

email_ = cell.Offset(1, 4).Value
email2_ = cell.Offset(1, 5).Value
cc = cell.Offset(1, 6).Value
subject_ = cell.Offset(1, 7).Value
path_ = cell.Offset(1, 8).Value



'Create Mail Item and send it
Set MItem = OutlookApp.CreateItem(0)
With MItem
.To = email_ & ";" & email2_
.cc = cc
.Subject = subject_
.htmlbody = "Dear All," & "</p>" _
& "<br>" _
& "Please find updated statement of accounts for your reference and payment persual.<br>" _
& "<br>" _
& "Kindly review all Line items and confirm payments whichs needs to be settled before the end of the month.<br>" _
& "<br>" _
& "Kindly feedback on status of past due invoice and do let me know shall you require anything else.<br>" _
& "<br>" _
& "<br>" _
& "<br>" _
& "Thanks and Regards,<br>" _
& "XXXXX<br>" _
& "XXXXX,<br>" _
& "XXXXX<br>" _
& "XXXXX<br>" _
& "XXXXX<br>" _
& "XXXXX<br>" _


.Attachments.Add path_

.DeleteAfterSubmit = False
.Send
End With
Next
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,214,587
Messages
6,120,405
Members
448,958
Latest member
Hat4Life

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