+ Reply to Thread
Results 1 to 4 of 4

Send personalized mass emails with multiple attachments

Hybrid View

  1. #1
    Registered User
    Join Date
    06-18-2014
    Location
    tirana,albania
    MS-Off Ver
    2013
    Posts
    8

    Send personalized mass emails with multiple attachments

    Hi,

    i need to add to my VBA code multiple attachments possibility loop till 5 attachment
    from column F to J if blank resume to next

    please could anyone help

    thank you

    note:beow the code , attached the file

    Sub SendEmail(what_address As String, CCs As String, subject_line As String, mail_body As String, FilePathtoAdd As String)

    Dim OlApp As Outlook.Application
    Set OlApp = CreateObject("Outlook.Application")

    Dim OlMail As Outlook.MailItem
    Set OlMail = OlApp.CreateItem(olMailItem)

    Dim myAttachments As Outlook.attachments
    Set myAttachments = OlMail.attachments

    OlMail.To = what_address
    OlMail.CC = CCs
    OlMail.Subject = subject_line
    OlMail.Body = mail_body
    OlMail.attachments.Add FilePathtoAdd

    OlMail.Send

    End Sub

    Sub SendMassEmail()
    row_number = 1
    column_number = 1

    Do
    DoEvents
    row_number = row_number + 1
    'Do
    'DoEvents
    'column_number = column_number + 1

    'If FilePathtoAdd <> "" Then
    ' OlMail.attachments.Add FilePathtoAdd
    ' End If

    ' If OlMail.attachments.Count <> 0 Then
    ' For Each myAttachments In OlMail.attachments
    ' myAttachments.Item(i).SaveAsFile FilePathtoAdd
    '
    ' i = i + 1
    ' Next myAttachments
    ' Msg.UnRead = False
    ' End If



    Dim mail_body_message As String
    Dim full_name As String
    Dim Invoice_period As String
    Dim Link As String

    mail_body_message = Sheet1.Range("K2")
    full_name = Sheet1.Range("C" & row_number)
    Invoice_period = Sheet1.Range("E" & row_number)
    mail_body_message = Replace(mail_body_message, "replace_name_here", full_name)
    mail_body_message = Replace(mail_body_message, "Invoice_period_replace", Invoice_period)

    Call SendEmail(Sheet1.Range("A" & row_number), Sheet1.Range("B" & row_number), Sheet1.Range("D" & row_number), mail_body_message, Sheet1.Range("F" & row_number))




    Loop Until row_number = 6
    'Loop Until column_number = 5

    MsgBox "Mass Emails Sent Succesfully !"

    End Sub
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Send personalized mass emails with multiple attachments

    you'll need to either pass the range in to the function as an extra argument, so add rng as excel.range or have it in your code

    then in your code

    for each c in rng.cells
      if c.value <>"" then  .atttachments.add(c.value)
    next c
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    06-18-2014
    Location
    tirana,albania
    MS-Off Ver
    2013
    Posts
    8

    Re: Send personalized mass emails with multiple attachments

    please could add it and send full code because i tried but not woking

    thank you

  4. #4
    Registered User
    Join Date
    06-18-2014
    Location
    tirana,albania
    MS-Off Ver
    2013
    Posts
    8

    Re: Send personalized mass emails with multiple attachments

    please could anyone resend this VBA code functional from zero to five attachments optional
    currently its working only with one attachments
    help please!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro To Send Emails with PDF: Multiple Emails and PDF's
    By totoga12 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 03-19-2014, 06:13 PM
  2. [SOLVED] VBA to send emails with different attachments to each seperate email
    By gillyr7 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-14-2014, 02:25 PM
  3. VBA to send multiple emails with different attachments
    By gillyr7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2014, 02:33 PM
  4. Problem using a macro to send multiple emails with separate attachments
    By joshthorntonwhite in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2013, 07:31 AM
  5. [SOLVED] Need Macro that will create & send emails w/ attachments from a list in Excel
    By rollerden in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2012, 07:02 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1