Results 1 to 2 of 2

Thread: VBA to Email diffrent email addresses and add dynamic excel file attachment
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Oct 2014
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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 by russellheidi; May 26th, 2019 at 01:07 PM. Reason: Posted Picture wrongly

  2. #2
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    6,944
    Post Thanks / Like
    Mentioned
    85 Post(s)
    Tagged
    15 Thread(s)

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

    You can use this small application to send several emails with different Subject and with different files.

    https://www.dropbox.com/s/a0dpmr57n2...mple.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
    Regards Dante Amor

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •