KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 453
- Office Version
- 2016
- Platform
- Windows
Hi, I use this VBA code to send mail with Attached file using outlook. But I for this error message see the attachment, someone who can help.
Any help will be appreciated.
Best regards Klaus W
Any help will be appreciated.
Best regards Klaus W
VBA Code:
Option Explicit
Private Sub Send_Email_to_an_Address_in_Cell()
Dim MyOutlook As Object
Set MyOutlook = CreateObject("Outlook.Application")
Dim MyMail As Object
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.To = Range("a17").Value '& "; " & Range("a18").Value & "; " & Range("a19").Value & "; " & Range("a20").Value
MyMail.Subject = Range("a24").Value
MyMail.Body = Range("a25").Value & vbNewLine & vbNewLine & Range("a26").Value & vbNewLine & _
Range("a27").Value & vbNewLine & Range("a28").Value & vbNewLine & Range("a28").Value & vbNewLine & _
Range("a29").Value & vbNewLine & _
Range("a30").Value
Attached_File = Range("a31").Value
MyMail.Attachments.Add Attached_File
MyMail.Send
End Sub