Add Workbook to a Mail Attachment - VBA

Copper Contributor

Hello,

 

Is there a VBA code to Add Workbook to a Mail Attachment ?

2 Replies

@SaraAb 

Here is a VBA code and an example file.

 

Sub Excel_Workbook_send_with_Outlook_()
Dim Nachricht As Object, OutApp As Object
Set OutApp = CreateObject("Outlook.Application")
Dim AWS As String
'The active workbook is sent as a mail
AWS = ThisWorkbook.FullName
InitializeOutlook = True
Set Nachricht = OutApp.CreateItem(0)
With Nachricht
        .To = "lino.excelsius@gmail.com"
        .Subject = " Test report from Microsoft Excel Community " & Date & Time
        .attachments.Add AWS
        .Body = "This is a Test." & vbCrLf & " Please ignore this message "
        'The mail is displayed again here
         .Display
         'Here the mail is immediately placed in the outbox
         'Mail.Send
End With
End Sub

 

 

 

At the same time, I can only recommend this site.

Mail from Excel

 

I would be happy to know if I could help.

 

NikolinoDE

Was the answer useful? Mark them as helpful!

This will help all forum participants.