ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Attaching more than one file to an email with VBA (https://www.excelbanter.com/excel-programming/424114-attaching-more-than-one-file-email-vba.html)

Tom Joseph

Attaching more than one file to an email with VBA
 
Can someone please advise on the proper syntax for attaching more than one
file to a message?

The error occurs at:

.Attachments.Add FilenameStr2


Thanks,



Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

'On Error Resume Next
With OutMail
.To = emails
.CC = ""
.BCC = ""
.Subject = "Hourly TAT Performance: " & _
Worksheets("Labels").Cells(4, i).Value & " - " & _
Sheets("Main").Range("AB8").Value
.Body = "Reports attached"
' .BodyFormat = olFormatPlain 'testing for text format
.Attachments.Add FilenameStr
.Attachments.Add FilenameStr2
.Attachments.Add FilenameStr3
.Attachments.Add FilenameStr4
.Send 'or use .Display
End With


Ron de Bruin

Attaching more than one file to an email with VBA
 
Check if this file exist

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Tom Joseph" wrote in message ...
Can someone please advise on the proper syntax for attaching more than one
file to a message?

The error occurs at:

.Attachments.Add FilenameStr2


Thanks,



Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

'On Error Resume Next
With OutMail
.To = emails
.CC = ""
.BCC = ""
.Subject = "Hourly TAT Performance: " & _
Worksheets("Labels").Cells(4, i).Value & " - " & _
Sheets("Main").Range("AB8").Value
.Body = "Reports attached"
' .BodyFormat = olFormatPlain 'testing for text format
.Attachments.Add FilenameStr
.Attachments.Add FilenameStr2
.Attachments.Add FilenameStr3
.Attachments.Add FilenameStr4
.Send 'or use .Display
End With


Tom Joseph

Attaching more than one file to an email with VBA
 
Thanks Ron. I had the files renaming as the same file, so the attachement
instruction failed.


"Ron de Bruin" wrote:

Check if this file exist

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Tom Joseph" wrote in message ...
Can someone please advise on the proper syntax for attaching more than one
file to a message?

The error occurs at:

.Attachments.Add FilenameStr2


Thanks,



Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

'On Error Resume Next
With OutMail
.To = emails
.CC = ""
.BCC = ""
.Subject = "Hourly TAT Performance: " & _
Worksheets("Labels").Cells(4, i).Value & " - " & _
Sheets("Main").Range("AB8").Value
.Body = "Reports attached"
' .BodyFormat = olFormatPlain 'testing for text format
.Attachments.Add FilenameStr
.Attachments.Add FilenameStr2
.Attachments.Add FilenameStr3
.Attachments.Add FilenameStr4
.Send 'or use .Display
End With




All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com