Emailing a sheet. - this should b easy - kinda urgent!

Sami

Board Regular
Joined
Mar 4, 2002
Messages
122
Ive got this code for emailing the sheet ReOrderSheet when the button is pressed:

Sub EmailSupplierWundpet()
'
' EmailSupplierWundpet Macro
' Emails Wundpet Ltd. the Re-order list
'

Set aEmail = aOutlook.CreateItem(olMailItem)

aEmail.Subject = "Oscarsons Pets & Provisions Re-Order List"

aEmail.Body = "Credit card number =."

aEmail.Attachments.Add ThisWorkbook.Path & "\data01.xls"

aEmail.Recipients.Add "orders@wundput.co.uk"

aEmail.Send

MsgBox "Email successfully sent."

End Sub

But this line keeps coming up in yellow and i dont know how to fix it? is there an easier way to doing this. is this code wrong?
 
Okay, here's the code I am currently using to send a worksheet from my workbook. I am using separate modules but you could probably use only one if you'd prefer.

Sub SendIt()

Application.ScreenUpdating = False
Application.DisplayAlerts = False
'make copy of sheet to e-mail
Sheet1.Copy
ActiveWorkbook.SaveAs Filename:="yourfilename.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=True, CreateBackup:=False
Application.Dialogs(xlDialogSendMail).Show _
arg1:="email@address.com", _
arg2:="your file name"
'this is a separate module(module code below)
'that closes the file that was just e-mailed
CloseWorkbook
'this is a separate module(code below)
'this deletes the file after sending
'you can omit this module if you don't mind
'the extra workbook
DeleteFile
End Sub

Code for CloseWorkbook module
Sub CloseWorkbook()
ActiveWorkbook.Close ("your file name")
End Sub

Code for deleting the file after sending

Sub DeleteFile()
Kill "complete path with filename where file was copied"
End Sub

This code works great for me. And thanks to your question I was able to complete my project.

Viper
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
hi, i would like to send e-mail in excel, but don't want any attachment in that e-mail, how can i do that?

i have done this:
Sub Forgot_Password()

Dim emailaddress As String
Dim password As String
emailaddress = ThisWorkbook.Sheets("Sheet1").Range("ea").Value
password = ThisWorkbook.Sheets("Sheet1").Range("pw").Value
Application.Dialogs(xlDialogSendMail).Show _
arg1:=emailaddress, _
arg2:=password
End Sub

because everytime i run this code, it attach a file that i am running. what do i need to do to stop it? i only want it to send value in a cell.
pls let me know!

e-mail: dreamcity88@hotmail.com
 
Upvote 0
y dont you make ur own new topic and ppl mite reply . im sorry but i cant help :S only a begginner
 
Upvote 0

Forum statistics

Threads
1,214,531
Messages
6,120,073
Members
448,943
Latest member
sharmarick

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