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:

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
9,727
Office Version
2007
Platform
Windows
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
 

Forum statistics

Threads
1,085,960
Messages
5,386,962
Members
402,026
Latest member
rudyd06

Some videos you may like

This Week's Hot Topics

Top