Sounds like, since there is more than one file you need to attach at a time that you probably need to loop in that folder to capture each and every xls file?
You can do this with a foreach loop or for loop.
Attaching them to outlook may be tricky.
You can do this an incorporate a for or foreach loop into it to create multiple attachments.
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Startup
AddAttachment()
End Sub
Private Sub AddAttachment()
Dim mail As Outlook.MailItem = _
TryCast(Me.Application.CreateItem _
(Outlook.OlItemType.olMailItem), _
Outlook.MailItem)
mail.Subject = "An attachment for you!"
/********************* Modify *************************/
Dim attachment As OpenFileDialog = _
New OpenFileDialog()
attachment.Title = "Select a file to send"
attachment.ShowDialog()
If attachment.FileName.Length > 0 Then
mail.Attachments.Add( _
attachment.FileName, _
Outlook.OlAttachmentType.olByValue, _
1, _
attachment.FileName)
/**************** To New Code Added ***********************/
/* VB code loops through files and attaches.
Re: Email with multiple attachments
With a comma-separated list of full file names in the B cell, replace the line:
Code: (Note: You could use a variable for the file and even file path? That is what I do in SSIS)
*/
.attachments.Add filepath
//with:
//Code:
Dim files As Variant, file As Variant
//FilePath
files = Split(C:\_BISolutions\*.xls, ",")
For Each file In files
.attachments.Add file
Next
/********************************************************/
mail.Recipients.Add("Armando Pinto")
mail.Send()
End If
End Sub