weaselmcguff
Board Regular
- Joined
- Feb 24, 2006
- Messages
- 246
Hello,
I am trying to attach multiple files to an automatically generated email. I know what 1 of the files names is going to be. But I am not sure if there are others files and what the names are going to be. I do know where they are located. I want all the files in that sub directory to be attached to the email.
I know how to do multiple files IF I know the names. But in this case I will not know if there are any other files and if there are wont know the name. I do know that they all will have the .JPG extension.
Here is my code for the sending of the email.
With OutMail
If email2 = "" Then
email2 = Application.InputBox("Please enter Email To Automatically Email this To:")
Worksheets("sheet2").Range("a45").Value = email2
Else
.To = email2 ' Who it is going to
.CC = email3 'CC to who it is going to
.Subject = subject1 ' sugbject of email
.Body = msgbody 'template for the body of the email
.Attachments.Add dir2 & thisfile & ".xls" 'dir2 is location where file is. thisfile is name and .xls extension
.Attachments.Add dir2 & "2.jpg" 'here adding the 2.jpg file from the dir2 location
'.Attachments.Add ActiveWorkbook.FullName
.Send 'or use .Display
End If
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
I can not figure out how to add multiple if any .jpg files to the email
Any suggestions.
Thanks for your time
I am trying to attach multiple files to an automatically generated email. I know what 1 of the files names is going to be. But I am not sure if there are others files and what the names are going to be. I do know where they are located. I want all the files in that sub directory to be attached to the email.
I know how to do multiple files IF I know the names. But in this case I will not know if there are any other files and if there are wont know the name. I do know that they all will have the .JPG extension.
Here is my code for the sending of the email.
With OutMail
If email2 = "" Then
email2 = Application.InputBox("Please enter Email To Automatically Email this To:")
Worksheets("sheet2").Range("a45").Value = email2
Else
.To = email2 ' Who it is going to
.CC = email3 'CC to who it is going to
.Subject = subject1 ' sugbject of email
.Body = msgbody 'template for the body of the email
.Attachments.Add dir2 & thisfile & ".xls" 'dir2 is location where file is. thisfile is name and .xls extension
.Attachments.Add dir2 & "2.jpg" 'here adding the 2.jpg file from the dir2 location
'.Attachments.Add ActiveWorkbook.FullName
.Send 'or use .Display
End If
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
I can not figure out how to add multiple if any .jpg files to the email
Any suggestions.
Thanks for your time