0

Trying to get this macro to attach the active workbook to email sent through outlook. I can get the e-mail send (it is also sending a clip from one of the sheets as the body of the e-mail. The email sends, but will not attach the file.

    Sub EmailRange()
'email specified range as the body of an e-mail
Dim WorkRng As Range
Dim Answer As String
Dim sht As Worksheet
Dim newname As String

On Error Resume Next
   



ActiveWorkbook.Save


Set WorkRng = Sheet5.Range("A1:F17")

Application.ScreenUpdating = False
WorkRng.Select

ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
    .Attachments.Add ActiveWorkbook.FullName
    .Introduction = "Borst Daily KPI Report " & Range("A2")
    .Item.To = "jeff.graser@borstauto.com;"
    .Item.Subject = "Borst Daily KPI Report " & Range("A2")
    .Item.Send
    
    
End With

Application.ScreenUpdating = True
End Sub

I have tried a number of ways that I have found to do this, but can't seem to get the e-mail to attach the workbook. I have tried to specify the file path and name, I have tried moving the line .attachements.add... to different places within the code. I have tried saving the workbook to another filename and then sending. No luck.

JLGAZ
  • 15
  • 3
  • 2
    Seems like you need `.Item.Attachments.Add` [see here](https://stackoverflow.com/questions/59426853/add-a-file-using-vba-mailenvelope). I would remove `On Error Resume Next` as it is hiding the error. – CDP1802 Apr 16 '23 at 21:47
  • This was the issue, thought I had tried that at one point, but probably had something else wrong. Thank you! .Item.Attachements.Add was the solution. – JLGAZ Apr 17 '23 at 14:33

0 Answers0