+ Reply to Thread
Results 1 to 6 of 6

Attachments when sending bulk emails

  1. #1
    Registered User
    Join Date
    05-31-2013
    Location
    SA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Attachments when sending bulk emails

    Hi all,

    Hoping someone can help me here. I am using the below code to send out bulk emails. This works like a charm. I however need to add one and sometimes multiple attachements, be that pdf or word files. How do I do this and what code would I use? I have tried so many variants but just cannot get this to work.

    Current working code below excluding being able to add attachments.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 02-10-2015 at 06:13 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Attachments when sending bulk emails

    Hello bruskieza,

    Welcome to the Forum!

    I modified your macro to take the path of the file(s) to attach. The files paths need to separated with a semi-colon ";".

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Attachments when sending bulk emails

    Hello bruskieza,

    Welcome to the Forum!

    I modified your macro to take the path of the file(s) to attach. The files paths need to separated with a semi-colon ";".

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-31-2013
    Location
    SA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Attachments when sending bulk emails

    Thanks Leith,

    So I added your rows into my code as per below but get an error on If File <> "" Then .Attachments.Add File, 1. Sorry, very new to this coding so apologize if I am being very doff here. Learning as I go along.

    Sub SendEmail(what_address As String, subject_line As String, mail_body As String, Optional FilesToAttach As Variant)

    ' SendBulkEmail Macro

    '
    Dim File As Variant
    Dim olApp As Object
    Dim InBox As Object

    Const olMailItem = 0

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


    Dim olmail As Outlook.MailItem
    Set olmail = olApp.CreateItem(olMailItem)

    olmail.To = what_address
    olmail.Subject = subject_line
    olmail.Body = mail_body
    olmail.Send

    End Sub
    Sub SendBulkEmail()

    row_number = 1

    Do
    DoEvents
    row_number = row_number + 1
    Dim mail_body_message As String
    Dim first_name As String
    Dim Last_Row_IN_Column_A As String


    mail_body_message = Sheet2.Range("A1")
    first_name = Sheet1.Range("B" & row_number)
    mail_body_message = Replace(mail_body_message, "replace_name_here", first_name)
    If Not IsMissing(FilesToAttach) Then
    For Each File In Split(FilesToAttach, "C:\test.txt")
    If File <> "" Then .Attachments.Add File, 1
    Next File
    Call SendEmail(Sheet1.Range("A" & row_number), "Compliments of the season", mail_body_message)
    Last_Row_IN_Column_A = Sheet1.Range("A999999").End(xlUp).Row


    Loop Until row_number = Last_Row_IN_Column_A
    MsgBox "Done like a bun!"

    End Sub

  5. #5
    Registered User
    Join Date
    05-31-2013
    Location
    SA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Attachments when sending bulk emails

    Thanks Leith,

    So I added your rows into my code as per below but get an error on If File <> "" Then .Attachments.Add File, 1. Sorry, very new to this coding so apologize if I am being very doff here. Learning as I go along.

    Sub SendEmail(what_address As String, subject_line As String, mail_body As String, Optional FilesToAttach As Variant)

    ' SendBulkEmail Macro

    '
    Dim File As Variant
    Dim olApp As Object
    Dim InBox As Object

    Const olMailItem = 0

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


    Dim olmail As Outlook.MailItem
    Set olmail = olApp.CreateItem(olMailItem)

    olmail.To = what_address
    olmail.Subject = subject_line
    olmail.Body = mail_body
    olmail.Send

    End Sub
    Sub SendBulkEmail()

    row_number = 1

    Do
    DoEvents
    row_number = row_number + 1
    Dim mail_body_message As String
    Dim first_name As String
    Dim Last_Row_IN_Column_A As String


    mail_body_message = Sheet2.Range("A1")
    first_name = Sheet1.Range("B" & row_number)
    mail_body_message = Replace(mail_body_message, "replace_name_here", first_name)
    If Not IsMissing(FilesToAttach) Then
    For Each File In Split(FilesToAttach, "C:\test.txt")
    If File <> "" Then .Attachments.Add File, 1
    Next File
    Call SendEmail(Sheet1.Range("A" & row_number), "Compliments of the season", mail_body_message)
    Last_Row_IN_Column_A = Sheet1.Range("A999999").End(xlUp).Row


    Loop Until row_number = Last_Row_IN_Column_A
    MsgBox "Done like a bun!"

    End Sub

  6. #6
    Registered User
    Join Date
    05-31-2013
    Location
    SA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Attachments when sending bulk emails

    Hi guys,
    Still stuck with this. Help!?

+ 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. Bulk emails with individual attachments.
    By sureshpunna in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2014, 03:55 PM
  2. Excel containing macro to send bulk mails from outlook with multiple attachments
    By amandeep08 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2013, 02:19 PM
  3. [SOLVED] Sending Outlook emails from Excel; Limits to three emails only?
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2013, 06:53 AM
  4. Sending macro emails using excel: Send emails with their passwords.
    By loveisblind in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 03:16 PM
  5. Replies: 0
    Last Post: 12-15-2005, 09:50 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