email with Attachments only one sheet

Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

I want to create macro, which will be sending email with attachments.
Code:
Sub create_email()
Dim wb1 As Workbook
Dim ws1 As Worksheet
Set wb1 = ActiveWorkbook
Set ws1 = wb1.Worksheets("row_data")
'******************************************************
'copy range
Dim wb_e As Workbook
Dim ws_e As Worksheet

Workbooks.Add
Set wb_e = ActiveWorkbook
Set ws_e = wb_e.Worksheets(1)

ws1.Columns("A:Z").Copy
ws_e.Paste
Application.CutCopyMode = False
'******************************************************
Dim Email_Subject, Email_Send_From, Email_Send_To, Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant

Email_Subject = ""
Email_Send_From = ""
Email_Send_To = ""
Email_Body = ""
    
    Set Mail_Object = CreateObject("Outlook.Application")
    
    Set Mail_Single = Mail_Object.CreateItem(0)
        
        With Mail_Single
            .Subject = Email_Subject
            .To = Email_Send_To
            .cc = Email_Cc
             .Body = Email_Body
            .HTMLBody = Email_Body
             .Attachments.Add wb_e.FullName
            .Display
        End With

End Sub

Because as a attachment I want to add just sheet with data (NOT WHOLE WORKBOOK), I copy the data to new workbook. But then I get error:
run-time error '-2147024894(80070002)':
cannot find this file. Verify the path and file name are correct.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top