EMAIL AUTOMATION

rebelhunter

New Member
Joined
Oct 24, 2002
Messages
11
hey guys and gals!!

Heres coding of a macro which emails multiple excel files to multiple recipients.
For the macro to work, insert files to send under column A and email groupings created in outlook under column B.:

Private Sub CommandButton1_Click()


Dim aOutlook As Outlook.Application, aEmail As Outlook.MailItem
CRLF = Chr(10) & Chr(13)

Application.ScreenUpdating = False

DATA = Sheets("sheet1").Range("A1:A15")
CROW = 1

Set aOutlook = GetObject(, "Outlook.Application")

DATA = Sheets("sheet1").Range("A1:A15")
CROW = 1

For Each MAILFILE In DATA

Set aEmail = aOutlook.CreateItem(olmailitem)

aEmail.Subject = "Daily " & MAILFILE & " for your perusal."

aEmail.Body = "Please find attached the " & MAILFILE & " for today." & CRLF & CRLF

aEmail.Recipients.Add Sheets("sheet1").Range("B" & CROW)

aEmail.ATTACHMENTS.Add ("j:misellaneousutrustpricingut mail attachments" & MAILFILE)

aEmail.Send

CROW = CROW + 1

Next MAILFILE

MsgBox "Emails successfully sent."



End Sub



Private Sub EMAIL_Click()

End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

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