Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access email add attachement

Posted on 2013-02-06
3
Medium Priority
?
386 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 1400 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 600 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

971 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