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

NumberBUAmountCurrencySupplier NameCreation DateInvoice DateStatusEmail IDPending FromLinesProjectTypePO #
123AU434.50AUDSupplier Name8/26/198/19/19INITIATEDx@y.com9/4/198XYZPOPO NUMBER
456MY187.00AUDSupplier Name5/9/193/11/19INITIATEDa@b.com9/10/192ABCNon-PO
789IN187.00AUDSupplier Name5/9/193/11/19INITIATEDc@d.com9/10/192DEF
Non-PO

<colgroup><col span="6"><col><col span="7"></colgroup><tbody>
</tbody>

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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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,213,497
Messages
6,113,999
Members
448,541
Latest member
iparraguirre89

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