Sending Email through a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using the following in vbe for a particular workbook. I would like to be
able to key in a message or a subject before I actually send the file. I
just want to have some control on the file being sent. Can this even be done?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.SendMail Recipients:="recipient@address"
End Sub
 
Hi rojobrown

With SendMail the only way to stop the file is to leave the E-mail address empty.
See example 2

Sub Mail_workbook_1()
ActiveWorkbook.SendMail "(e-mail address removed)", _
"This is the Subject line"
End Sub


Sub Mail_workbook_2()
ActiveWorkbook.SendMail "", _
"This is the Subject line"
End Sub

If you use Outlook you have more options (change Send to Display)
See my site for code examples
http://www.rondebruin.nl/sendmail.htm
 
How can I create it in my personal workbook so it doesn't get overwritten
each time I run the file?
--
Thanks a bunch!
rojobrown


Ron de Bruin said:
Hi rojobrown

With SendMail the only way to stop the file is to leave the E-mail address empty.
See example 2

Sub Mail_workbook_1()
ActiveWorkbook.SendMail "(e-mail address removed)", _
"This is the Subject line"
End Sub


Sub Mail_workbook_2()
ActiveWorkbook.SendMail "", _
"This is the Subject line"
End Sub

If you use Outlook you have more options (change Send to Display)
See my site for code examples
http://www.rondebruin.nl/sendmail.htm
 
Or do you want to know how to put it there

Alt-F11

See personal.xls on the left
Expand it and click on a module
Copy /paste the macro there
Alt-q to go back to excel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top