Multiple emails with each row data

Keerthiv

New Member
Joined
Aug 29, 2019
Messages
14
Dear All,

I have this excel data where am trying to send individual email along with the data from each row associated to that email id. Below is the format

[TABLE="width: 945"]
<colgroup><col span="6"><col><col span="7"></colgroup><tbody>[TR]
[TD]Number[/TD]
[TD]BU[/TD]
[TD]Amount[/TD]
[TD]Currency[/TD]
[TD]Supplier Name[/TD]
[TD]Creation Date[/TD]
[TD]Invoice Date[/TD]
[TD]Status[/TD]
[TD]Email ID[/TD]
[TD]Pending From[/TD]
[TD]Lines[/TD]
[TD]Project[/TD]
[TD]Type[/TD]
[TD]PO #[/TD]
[/TR]
[TR]
[TD]123[/TD]
[TD]AU[/TD]
[TD]434.50[/TD]
[TD]AUD[/TD]
[TD]Supplier Name[/TD]
[TD]8/26/19[/TD]
[TD]8/19/19[/TD]
[TD]INITIATED[/TD]
[TD]x@y.com[/TD]
[TD]9/4/19[/TD]
[TD]8[/TD]
[TD]XYZ[/TD]
[TD]PO[/TD]
[TD]PO NUMBER[/TD]
[/TR]
[TR]
[TD]456[/TD]
[TD]MY[/TD]
[TD]187.00[/TD]
[TD]AUD[/TD]
[TD]Supplier Name[/TD]
[TD]5/9/19[/TD]
[TD]3/11/19[/TD]
[TD]INITIATED[/TD]
[TD]a@b.com[/TD]
[TD]9/10/19[/TD]
[TD]2[/TD]
[TD]ABC[/TD]
[TD]Non-PO[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]789[/TD]
[TD]IN[/TD]
[TD]187.00[/TD]
[TD]AUD[/TD]
[TD]Supplier Name[/TD]
[TD]5/9/19[/TD]
[TD]3/11/19[/TD]
[TD]INITIATED[/TD]
[TD]c@d.com[/TD]
[TD]9/10/19[/TD]
[TD]2[/TD]
[TD]DEF
[/TD]
[TD]Non-PO[/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]

The body of the email should be

Hi,
The below listed invoice is pending for your kind approval

BU:
Number:
Invoice Date:
Amount:
Supplier Name:
Currency:
Pending From:

Regards,
Keerthi

I tried the below code but not working for some reason. Can you please help


Sub Send_Email()
Dim rng As Range
For Each rng In Range("I1:I5")
Call mymacro(rng)
Next rng
End Sub
Private Sub mymacro(rng As Range)
Dim OutApp As Object
Dim OutMail As Object
Dim Cell As Range
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = rng.Value
.CC = ""
.BCC = ""
.Subject = "URGENT - Approval Pending"
.Body = "Hi," & vbNewLine = "The below listed invoice is pending for your kind approval." & _
vbNewLine = "BU: " & Cells(Cell.Row, "B").Value
.Display
'.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Thanks
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
You have a list of items to include in the body, but you only have one reference in your sample. I'm assuming you know how to add the rest.
You didn't say what part wasn't working, but I'm assuming it's the body. Two things I see - the use of vbNewLine and the cell reference.
Try this instead:

Code:
    .Body = "Hi," & vbCr & _
        "The below listed invoice is pending for your kind approval." & vbCr & _
        "BU: " & Cells(rng.Row, "B").Value

The vbCR don't have to be on the line i show them - could be on the next. That's just personal style. Nor do you have to actually start text after a vbCR on a new line.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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