Solved

Access email add attachement

Posted on 2013-02-06
3
376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

751 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