Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 30081

Excel 2010 E-mail VBA send entire workbook

$
0
0

I have been looking for a VBA that can send the entire workbook.

I found this

    Sub Mail()

    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next

    With OutMail
        .To = "mymail@domain.com"
        .CC = ""
        .BCC = ""
        .Subject = Range("A1").Value
        .body = ""
        .Attachments.Add ActiveWorkbook.FullName
        .send
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

But when opening the sent mail, the workbook is all empty. So I have to save the workbook before using VBA.

Is there a workaround for this, so it just work as normal File -> Save and send -> Send as attachment?


Viewing all articles
Browse latest Browse all 30081

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>