Results 1 to 2 of 2
  1. #1
    kelkan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    26

    Send email in Outlook with attachment

    I have set up my database so that I can send an email with the click of a command button; however, I am unable to figure out how to attach a report to the email. I've tried several options (.attachment.add "rptTrainingRequests" along with others) and Ican send the email but there is no attachement. Here is the code I have written so far:

    Private Sub cmdSend_Click()
    Dim olApp As Object
    Dim objMail As Object

    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open'
    If Err Then 'Outlook is not open'
    End If

    Set olApp = CreateObject("Outlook.Application") 'Create a new instance of Outlook'
    'Create e-mail item
    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
    'Set body format to HTML


    .BodyFormat = olFormatHTML
    .to = "EMail Address Here"
    .Subject = "Training Request"
    .HTMLBody = "Please see attached report and add employees to the training classes requested. Thank you."
    .Attachments.Add "rptTrainingRequests"
    .send

    End With
    MsgBox "Your request has been sent."

    End Sub

    Suggestions?

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

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

Similar Threads

  1. Send Email with Attachment VBA Code
    By kevins in forum Programming
    Replies: 2
    Last Post: 10-03-2012, 01:21 PM
  2. Replies: 1
    Last Post: 02-14-2012, 07:08 PM
  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

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