Solved

Access email add attachement

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

706 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

16 Experts available now in Live!

Get 1:1 Help Now