Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto mail from Excell 1

Status
Not open for further replies.

smithcza

Programmer
Jan 7, 2005
80
ZA
Hi. How can I save a excell workbook and mail it to a specified address using code (via a button)
Regards,
Smithcza

SmithcZA
 
Have a look at the SendMail method of the Workbook object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi.

I am still new with this one, can you please help.

Look at my code, this is what I got from the excel help file, when i try to use it, it errors "Object doesn't support this object or method" - highlighting the "With Aplication.ActiveDocument.MailEnvelope" line

Sub SendMail(ByVal strRecipient As String)

'Use a With...End With block to reference the MsoEnvelope object.
With Application.ActiveDocument.MailEnvelope

'Add some introductory text before the body of the e-mail.
.Introduction = "Please read this and send me your comments."

'Return a Microsoft Outlook MailItem object that
'you can use to send the document.
With .Item

'All of the mail item settings are saved with the document.
'When you add a recipient to the Recipients collection
'or change other properties, these settings will persist.
.Recipients.Add strRecipient
.Subject = "Here is the document."

'The body of this message will be
'the content of the active document.
.Send
End With
End With
End Sub

SmithcZA
 
that's funny - the help file for Sendmail uses this as an example:
Code:
ActiveWorkbook.SendMail recipients:="Jean Selva"

no mention of using the MAilEnvelope object - anyhoo, I would imagine the error is being caused as you are trying to refer to the activedocument
there is no such object in excel - you need to use activeworkbook

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
if all you want to do is send a file and you're not bothered about subject lines / text etc, I don't see any reason not to use it.......

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
I never want to 'just send a file'. ;)

-----------
Regards,
Zack Barresse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top