Hi all, im having difficulty on adding the names of the attached files into the body of an email created by the following code.
It attaches files without any problems on Excel 2003 onwards but want to include into the body of the email the filenames of files attached.
Contract = Sheets("Prefs").Range("Y5").Value
Set Sh = Sheets("Quick Search")
Set OutApp = CreateObject("Outlook.Application")
Set rng = Sh.Range("AQ4:AQ33")
Set Rn = Workbooks("Speedmail.xls").Worksheets("Local").Range("W1")
If Application.WorksheetFunction.CountA(rng) > 0 Then
Set OutMail = OutApp.CreateItem(0)
With OutMail
.Subject = Contract
.body = "Hello," & vbLf & vbLf & "Please find attached your documents." & vbLf & "Many thanks" & vbLf & vbLf & Application.UserName
For Each FileCell In rng.SpecialCells(xlCellTypeConstants)
If Trim(FileCell) <> "" Then
If Dir(FileCell.Value) <> "" Then
.attachments.Add FileCell.Value
With Workbooks("Drawing Register.xls").Worksheets("Local")
.Range("A" & FileCell.Offset(0, -20) + 2 & ":T" & FileCell.Offset(0, -20) + 2).Copy Workbooks("Speedmail.xls").Worksheets("Local").Range("A" & Rn)
End With
Rn = Rn + 1
End If
End If
Next FileCell
Workbooks("Speedmail.xls").Close SaveChanges:=True
.attachments.Add ThisWorkbook.Path & "\" & "Speedmail.xls"
.display
End With
Set OutMail = Nothing
End If
Set OutApp = Nothing
It takes its list of files to attach from an array say 20 files including their paths and produces an email with all the files attached.
As well as the message produced by the Body part in the code, Im unsure how to make it add each filename into the body when it loops to add the files.
Any help is much appreciated.
Bookmarks