tags:

views:

21

answers:

2

I am using the following code to send an email with attachments. I can send one attachment but how can I send multiple attachments?

Dim vrAttachFilePath As String = "c:\users\ittahad\documents\abc.doc"
If vrAttachFilePath.Length > 0 Then
    oMail.Attachments.Add(New Net.Mail.Attachment(vrAttachFilePath))
End If
+1  A: 

You could add multiple elements to the Attachments collection:

oMail.Attachments.Add(New Net.Mail.Attachment(path1))
oMail.Attachments.Add(New Net.Mail.Attachment(path2))
oMail.Attachments.Add(New Net.Mail.Attachment(path3))
...
Darin Dimitrov
+1  A: 

Put quite simply:

Dim vrAttachFilePathFile1 As String = "c:\users\ittahad\documents\abc.doc"
Dim vrAttachFilePathFile1 As String = "c:\users\ittahad\documents\def.doc"

oMail.Attachments.Add(New Net.Mail.Attachment(vrAttachFilePathFile1))
oMail.Attachments.Add(New Net.Mail.Attachment(vrAttachFilePathFile2))

You can add as many attachments as you want simply by calling Attachments.Add with each attachment.

Rob