Send email with MULTIPLE ATTACHMENTS using CDO

I would like to have an ASP page that can send email with multiple attachment. Below is my code with 1 attachment and it is working.

SendMsg Mailto, MailCC, MailBCC, MailFrom, MailSub, MsgBody,"C:\\InetPub\wwwroot\"&mid(File.Path,35,len(File.Path))"
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

your going to have to change your sendmsg subroutine to accept an array of filenames, then loop through the file names and add the attacments.

Could you post your sendmsg subroutine

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

If you just modify your routine, as I have given an example of below, to check to see whether the attachment argument is a string or an array, you can allow multiple attachments or single attachments, without breaking any code that is only using single.

Here is my sample SendMsg subroutine:

Sub SendMsg (to, cc, bcc, from, subj, body, attach)
      Dim oMail
      Dim oFs
      Dim sAttach

      Set oMail = Server.CreateObject("CDONTS.NewMail")
      oMail.To = to
      If cc <> "" Then
            oMail.CC = cc
      End If
      If bcc <> "" Then
            oMail.BCC = bcc
      End If

      oMail.From = from
      If subj = "" Then
            oMail.Subject = "[no subject]"
            oMail.Subject = subj
      End If

      oMail.Body = body

      Set oFs = Server.CreateObject("Scripting.FileSystemObject")
      On Error Resume Next
      If IsArray(Attach) Then
            For i = 0 To Ubound(Attach)
                  sAttach = ""
                  If oFs.FileExists(attach(i)) Then
                        sAttach = attach(i)
                  ElseIf oFs.FileExists(Server.MapPath(attach(i))) Then
                        sAttach = Server.MapPath(attach(i))
                  End If
                  If sAttach <> "" Then
                        oMail.AttachFile sAttach
                  End If
            sAttach = ""
            If attach <> "" Then
                  If oFs.FileExists(attach) Then
                        sAttach = attach
                  ElseIf oFs.FileExists(Server.MapPath(attach)) Then
                        sAttach = Server.MapPath(attach)
                  End If

                  If sAttach <> "" Then
                        oMail.AttachFile sAttach
                  End If
            End If
      End If

      On Error GoTo 0
      Set oFs = Nothing


      Set oMail = Nothing
End Sub

- misty
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.