CarlStephens
Board Regular
- Joined
- Sep 25, 2020
- Messages
- 128
- Office Version
- 2016
- Platform
- Windows
Hello All,
Can anyone advise why the below code is not adding the attachment to the email in Outlook? Screenshot is below the code. Thank you
Can anyone advise why the below code is not adding the attachment to the email in Outlook? Screenshot is below the code. Thank you
VBA Code:
Sub Send_Single_Email()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Dim ws As Worksheet
Set ws = Sheets("3. Email New Joiners")
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
On Error Resume Next
With xOutMail
.To = ws.Range("C2").Value
.CC = ws.Range("C3").Value
.BCC = ws.Range("C4").Value
.Subject = ws.Range("C5").Value
.body = Join(Application.Transpose(ws.Range("C11", ws.Cells(ws.Rows.Count, "C").End(xlUp)).Value), vbCrLf)
.Attachments.Add = ws.Range("C7").Value
.Attachments.Add = ws.Range("C8").Value
.Attachments.Add = ws.Range("C9").Value
.Display
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Last edited by a moderator: