Results 1 to 2 of 2

Thread: VBA Macro for Bulks and an attachment

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    VBA Macro for Bulks and an attachment

    Hi,

    I am new to this forum. I have found a VBA code from the internet. Please can anyone help to modify it so it also attaches a file from "C:\Documents\CustomerQuestions.docx" with each outgoing email.


    Sub SendEmails(what_address As String, subject_line As String, mail_body As String)
    '
    ' SendEmails Macro
    '

    '
    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 SendMassEmails()

    row_number = 1

    Do
    DoEvents
    row_number = row_number + 1
    Call SendEmails(Sheet1.Range("A" & row_number), "Customer Questionnaire", Sheet1.Range("J2"))

    Loop Until row_number = 30 'there are only 29 customers in total


    End Sub

  2. #2
    Junior Member
    Join Date
    Aug 2013
    Posts
    18
    Rep Power
    0
    Add the below code before "Olmail.send" to attach the file

    olMail.Attachments.Add ("C:\Documents\CustomerQuestions.docx")

Similar Threads

  1. Replies: 26
    Last Post: 10-22-2019, 02:39 PM
  2. Replies: 2
    Last Post: 07-02-2013, 02:36 PM
  3. Replies: 6
    Last Post: 06-05-2013, 11:33 PM
  4. Check for Missing Attachment and Subject in Outlook
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 05-17-2013, 12:32 AM
  5. Replies: 4
    Last Post: 03-01-2013, 10:48 PM

Posting Permissions

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