Solved

Access email add attachement

Posted on 2013-02-06
3
374 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

828 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