Wrox Programmer Forums
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 9th, 2004, 04:57 AM
Authorized User
Join Date: Dec 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Email attachments

Hello all,

Does any know how to attach multiple files to outlook emails using VBA. Below is the code which i am using and woirks fine for single attachments.

  ' Create object variables
    Dim objOutlook As Outlook.Application
    Dim objMessage As Outlook.MailItem

    ' Create other variables
    Dim strFileName As String
    Dim strRecipient As String
    Dim strSubject As String
    Dim strBody As String
    Dim strTitle As String

    ' Open Outlook and create new mailitem
    Set objOutlook = CreateObject("Outlook.Application")
    Set objMessage = objOutlook.CreateItem(olMailItem)

       ' Assign values to variables
    strFileName = "c:\temp\testfile.xls"
    strRecipient = "tucker"
    strSubject = "Daily Report"
    strBody = "Please find attached daily report" & vbCrLf & vbCrLf
    strTitle = "Daily Report"

    ' Populate MailItem
    With objMessage
        .To = strRecipient
        .Subject = strSubject
        .Body = strBody
        .Attachments.Add strFileName, , , strTitle
    End With

    ' Release object variables
    Set objOutlook = Nothing
    Set objMessage = Nothing

Please Help

Old June 10th, 2004, 03:25 AM
Authorized User
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts

I would've thought you just add another

    .Attachments.Add strFileName, , , strTitle
having previously set strFileName (and strTitle) to new values of course

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Attachments with email arshad mahmood Classic ASP Professional 3 May 31st, 2006 08:13 PM
Email with Attachments echovue Access 2 March 22nd, 2005 10:36 AM
Email Attachments Doug Riede Classic ASP Basics 0 October 24th, 2003 11:11 AM
Sending email attachments KARENM Access VBA 2 August 8th, 2003 07:07 AM
Email w/Attachments aingalsbe PHP How-To 1 June 25th, 2003 04:48 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.