Results 1 to 3 of 3
  1. #1
    kevins is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    26

    Send Email with Attachment VBA Code

    Hey there,



    I have a button I use on a form to send automated emails to my candidates for interviews. It works great but I'd like to have it automatically attach a file as well. Anyone know how I can automatically include attachments? Code is below. Thanks!

    Private Sub Command342_Click()
    Dim strBody As String
    Dim strTo As String


    strBody = [First Name] & "," & Chr(13) & vbCrLf _
    & "It was a pleasure speaking with you today. We are confirmed to meet in the Harper Associates office on " & [Interview1] & " at " & [Harper Interview Time] & "." & Chr(13) & vbCrLf _
    & "Our address is 31000 Northwestern Highway, Suite 240, Farmington Hills, MI 48334. We are located on the NE corner of 13 Mile and Northwestern Highway (entrance is on Northwestern - look for the Level One Bank sign outside). View our location on Google Maps here: http://goo.gl/maps/WpMu." & Chr(13) & vbCrLf _
    & "Please also fill out the attached application and bring it with you when you come in. Thanks " & [First Name] & "," & " have a great day!" & Chr(13) & vbCrLf _
    & "Best Regards," & Chr(13) & vbCrLf _


    Debug.Print Len(strBody)
    strTo = [Contact Name] & IIf(Nz([E-mail Address]) <> "", " [" & [E-mail Address] & "]", "")
    DoCmd.SendObject , , , strTo, , , "Interview Confirmed at Harper Associates", strBody, True
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    To send a file you'd need to use Outlook automation:

    http://support.microsoft.com/?kbid=161088

    or CDO. SendObject can only send an attachment that it creates on the fly, using the first arguments.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    kevins is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    26
    Thanks, I'll give it a try.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 02-14-2012, 07:08 PM
  2. Replies: 4
    Last Post: 04-13-2011, 10:11 AM
  3. Replies: 1
    Last Post: 03-09-2011, 08:54 AM
  4. Send in Email Body vice Attachment
    By cassidym in forum Programming
    Replies: 2
    Last Post: 10-20-2010, 06:21 AM
  5. Beginner trying to send email with attachment
    By ahm in forum Programming
    Replies: 2
    Last Post: 03-24-2009, 08:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums