VBA to Email diffrent email addresses and add dynamic excel file attachment

russellheidi

New Member
Joined
Oct 26, 2014
Messages
4
Hi All


Could someone please help me write a VBA to automatically email a list of emailaddresses in Column A and add an Excelfile attachment for that email address which is in Column D. Column C is the root directoryfor where all the files are kept.


I have a low understanding of VBA, but an idea. So any supportwould be welcome with any instructions you think I may need.

See picture below as an example, but I am happy to changelayout if required.

Thanks Russ
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You can use this small application to send several emails with different Subject and with different files.

https://www.dropbox.com/s/a0dpmr57n2hp70v/Email5c sample.xlsm?dl=0


Code:
Sub Enviar_Correos()
'---
'  
'---
    '***Macro to send email
    col = Range("H1").Column
    For i = 2 To Range("B" & Rows.Count).End(xlUp).Row
        Set dam = CreateObject("Outlook.Application").CreateItem(0)
        '
        dam.To = Range("B" & i).Value           'To
        dam.Cc = Range("C" & i).Value           'With copy
        dam.Bcc = Range("D" & i).Value          'hide copy
        dam.Subject = Range("E" & i).Value      'subject
        dam.Body = Range("F" & i).Value         'body
        '
        For j = col To Cells(i, Columns.Count).End(xlToLeft).Column
            archivo = Cells(i, j).Value
            If archivo <> "" Then dam.Attachments.Add archivo
        Next
        dam.Send                                send
        'dam.Display                             'show
    Next
    MsgBox "End", vbInformation, "Regards"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,692
Messages
6,173,853
Members
452,535
Latest member
berdex

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