Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Send Email with CDO 4    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Multiple attachments
Paul Kiener 
      
2 years ago
I ultimately would like to send 2 files as attachments to multiple people.  But my current problem is adding the two files as attachments.
I have the program successfully adding 1 file, utilizing the "Attach" button and selecting the correct file; the program works and the email is sent.  I can also manually enter the path\file into the Attachment field, and again, the message is correctly sent with the intended attachment.  However, I cannot figure out how to enter the 2nd file.  If I attempt to enter both file names manually, I receive the error message: "Attachment file not found:  G:\My Drive\Eggs.xlsx; G:\My Drive\ChickensRecent.xlsx"

Any help with this would be appreciated.  Thank you in advance.
Sami Shamma  @Reply  
             
2 years ago
check out the following videos. You can use the same concept to select Mutiple attachments.
Load Multiple Images
Paul Kiener OP  @Reply  
      
2 years ago
Thank you, Sami, for the reply.  Yes, that video would be of benefit once I can determine the syntax for multiple attachments.  As I mentioned, if I manually type in "G:\My Drive\Eggs.xlsx; G:\My Drive\ChickensRecent.xlsx" or
'"G:\My Drive\Eggs.xlsx, G:\My Drive\ChickensRecent.xlsx", I receive the error message.  If I manually type in just one of those files, email is sent without any problems.  Once I figure out the syntax for multiple attachments, or determine if there is something else that I'm not aware, then I definitely will glean the information from the video "Load Multiple Images" for my project.
Kevin Robertson  @Reply  
          
2 years ago
In the SendMail function you need to loop through the attached files and split them on the semi-colon.

Example

Additional declarations:


    Dim AttachmentArray() As String
    Dim i As Integer


Add before the command to send the email

Details    ' Check if attachments are provided
    If Attachment <> "" Then
        ' Split the attachments string into an array
        AttachmentArray = Split(Attachment, ";")
            
        ' Iterate over the array and add each attachment
        For i = LBound(AttachmentArray) To UBound(AttachmentArray)
            Debug.Print "Adding attachment: " & Trim(AttachmentArray(i)) ' Debug output to check each attachment
            If Dir(Trim(AttachmentArray(i))) <> "" Then
                .AddAttachment Trim(AttachmentArray(i))
            Else
                MsgBox "Attachment file not found: " & Trim(AttachmentArray(i))
                Exit Function
            End If
        Next i
    End If


If you use the button to select your attachments the PickFile function will need to be modified to loop through the SelectedFiles.
Paul Kiener OP  @Reply  
      
2 years ago
Thank you, Kevin!  That worked like a charm.  I appreciate your help.
Kevin Robertson  @Reply  
          
2 years ago
You're welcome.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Send Email with CDO 4.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/10/2026 7:13:50 AM. PLT: 1s