VBA to Send Outlook Emails with Excel Information

chicka7684

New Member
Joined
May 15, 2017
Messages
10
I've figured out how to send an Outlook email with VBA (I'm a newbie with VBA), using specific information out of an Excel worksheet.

My Excel worksheet has the following information that I'm using in the VBA:

Column H = Email To
Column I = Email CC
Column J = Email Subject

The VBA code I have, that works for only 1 cell, is this:

Sub ABSInvoices()

Dim outlookApp As Outlook.Application
Dim myMail As Outlook.MailItem

Set outlookApp = New Outlook.Application
Set myMail = outlookApp.CreateItem(olMailItem)

myMail.To = Sheet1.Cells(2, 8)
myMail.CC = Sheet1.Cells(2, 9)
myMail.Subject = Sheet1.Cells(2, 10)
myMail.Body = "To Whom it May Concern," & Chr(10) & Chr(10) & "Attached is your invoice for review and payment. If you have any questions or concerns regarding payment, please contact our AR Department. Thank you!"

myMail.Display True

End Sub

I have this set to Display instead of Send because I need to attach different invoices to each email.

What I need is for this to Loop until I get to a row that is blank. I can end up with 1 row of information or 100 at any time I run this reporting... I just have no clue how to work in the Loop function.

Also, will this work for any worksheet that I create or only for the one I'm working with now? Is there a way to create a macro that would work with any worksheet I create?

Thanks in advance!!!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
if you research activesheet, then that would suffice, also a FOR NEXT loop would constrain the sending
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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