+ Reply to Thread
Results 1 to 5 of 5

VBA to email pdf files and attachments

Hybrid View

  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    Bedfordshire England
    MS-Off Ver
    Excel 2007
    Posts
    3

    VBA to email pdf files and attachments

    Hi
    I am looking for a spreadsheet that will enable me to send multipule emails to individuals
    and attach a pdf file & a word document
    Anyone got one already set up
    Many thanks
    Ann

  2. #2
    Registered User
    Join Date
    02-23-2011
    Location
    birmingham
    MS-Off Ver
    Excel 2003 to 2010
    Posts
    5

    Re: VBA to email pdf files and attachments

    I use this to send out emails to individual people with a word attachment.

    In Excel starting in Column A I have listed as follows:

    First Name Last Name Company Business Phone Home Phone Mobile Phone E-mail Address Subject Body Signature Send

    The send column is K and if that has a yes in it that person will received the email with attachment. Note you have to set the reference to use Outlook in the VBA screen in Excel, use Alt + F11 then select Tools menu and References search down for Microsoft Outlook XX . Object Library


    Sub EmailRangeList()
    'Using Object to create so works with all verisons
    'Column G holds the email addresses
    'Column A holds the salutation
    'Column K holds Yes or No to send
    'Adjusted code by Trevor Glover January 2012
        Dim OutApp As Object
        Dim OutMail As Object
        Dim cell As Range
    
        Application.ScreenUpdating = False
        Set OutApp = CreateObject("Outlook.Application")
    
        On Error GoTo cleanup
        Sheets("Availability").Activate
            For Each cell In Columns("G").Cells.SpecialCells(xlCellTypeConstants)
            If cell.Value Like "?*@?*.?*" And _
               LCase(Cells(cell.Row, "K").Value) = "yes" Then
    
                Set OutMail = OutApp.CreateItem(0)
                On Error Resume Next
                With OutMail
                    .To = cell.Value
                    .Subject = Cells(cell.Row, "H").Value
                    .Body = "Dear " & Cells(cell.Row, "A").Value _
                          & vbNewLine & vbNewLine & _
                          Cells(cell.Row, "I").Value _
                          & vbNewLine & vbNewLine & _
                          Cells(cell.Row, "J").Value
                          
                            '"Please find attached an update to my availability " '& '_
                            '"your account up to date"
                    'If you need an attachment use the line below
                    .Attachments.Add ("C:\\Desktop Jan 2009\Product list as at June 2012.doc")
                    .Send  'Or use .Display
                    '.Display
                End With
                On Error GoTo 0
                Set OutMail = Nothing
            End If
        Next cell
    
    cleanup:
        Set OutApp = Nothing
        Application.ScreenUpdating = True
    End Sub

  3. #3
    Registered User
    Join Date
    06-12-2012
    Location
    Bedfordshire England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA to email pdf files and attachments

    Hi
    Thanks for this
    You are talknig to a useless HR person
    Any chance of an example spreadsheet that I can then get someone to change
    Thanks
    Ann

  4. #4
    Registered User
    Join Date
    02-23-2011
    Location
    birmingham
    MS-Off Ver
    Excel 2003 to 2010
    Posts
    5

    Re: VBA to email pdf files and attachments

    Send Email Availability Update 01062012.xlsm

    See attached sample for you.

  5. #5
    Registered User
    Join Date
    06-12-2012
    Location
    Bedfordshire England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA to email pdf files and attachments

    Thank you so much
    Can I ask one more thing
    if I wanted to send an email to e.g.
    ann.henwood@*******.com and attach a file H/HR/Plld/AH
    Hannah.Williams@*****.com and attach a file H/HR/P11d/HW

    How would I do this ?

    Many thanks
    Ann

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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