Solved

Access email add attachement

Posted on 2013-02-06
3
371 Views
Last Modified: 2013-02-07
I'm using this code to email: -
    Dim objMsg As Object
    Set objMsg= CreateObject("CDO.Message")
    With objMsg
   
        .Subject = Subject
        .From = "user@domain.com"
        .To =  "user@domain.com"
        .TextBody = strMessText
        .AddAttachment ("file://" & strTempFile)

I want to add multiple attachments does anyone know the syntax?
0
Comment
Question by:HKFuey
3 Comments
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 350 total points
ID: 38860429
Dim objMsg As Object
    Set objMsg= CreateObject("CDO.Message")
    With objMsg
   
        .Subject = Subject
        .From = "user@domain.com"
        .To =  "user@domain.com"
        .TextBody = strMessText
        .AddAttachment ("file://" & strTempFile1)
        .AddAttachment ("file://" & strTempFile2)
        .AddAttachment ("file://" & strTempFile3)
0
 
LVL 31

Assisted Solution

by:Helen_Feddema
Helen_Feddema earned 150 total points
ID: 38861219
Those are actually links, not attachments.  If that is what you want (and the path is the same on the recipient's computer), it's fine.  But if not, here is the code for adding attachments:

Private Sub SendMailAttachment
'Created by Helen Feddema 5-19-2000
'Last modified 16-May-2010

On Error GoTo ErrorHandler

   Dim appOutlook As New Outlook.Application
   Dim msg As Outlook.MailItem
   Dim strFileName As String
   Dim strFilePath As String
   
   strFilePath = Application.CurrentProject.Path
   strFileName = strFilePath & "\Contacts.csv"
   
   'Save Contacts table as a text file in same folder as database
   DoCmd.TransferText acExportDelim, "Contacts Export Specification", _
      "tblContacts", strFileName, True
      
   'Create new mail message and attach text file to it
   Set msg = appOutlook.CreateItem(olMailItem)
   With msg
      .To = "John Doe"
      .Subject = "Contacts file you requested"
      .Body = "This file was exported from tblContacts on " & _
         Date & "." & vbCrLf & vbCrLf
      .Attachments.Add strFileName
      .Display
   End With
   
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub

Open in new window

0
 

Author Closing Comment

by:HKFuey
ID: 38863122
Thanks for the help
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now