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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send email from a vba script 1

Status
Not open for further replies.

randy4126

Programmer
Jun 2, 2001
62
US
How do you send an email message from a vba script?
thanks Randy
 
You can use

ActiveWorkbook.SendMail Recipients:=[MyDistribution List], Subject:=[EmailTitle] Store300

Store300@ftnetwork.com
 
Depends on the application your using it in.
In the hidden members of Excel you will also find something
which is called .hasroutingslip could be very interesting if
you automatically want to forward a workbook ie after each update. In Access what you could do is create a macro using the 'sendobjects' method.
 
Store300,

That lets you send a workbook, but does not let you send any "body" in the email message, or am I wrong?

What if I want to send a straight email, with text in the body, but not the workbook?

Roy
 
Roy,

Strangely enough Excel doesn't allow for simply adding body text to an email. I tend to use Access if I want to do this (why Access can and Excel can't is anyone's guess I'm afraid). Store300

Store300@ftnetwork.com
 
You can use MAPI to send an email with or without sending the Workbook. If you search Microsoft or Planetsourcecode.com/vb for MAPI you will find loads of examples. Straight VB ones should work with a little doctoring in VBA.
 
How come when you use mapi in a vba scrip? the code seems to be so fragile sometimes running fine and the next time you run it could run fine or give errors???
 
How about sending the Excel file as an attachment, is there a way for this to be done?
 
Ooops. I meant sending the Excel file as a shortcut. (It's been a long day)
 
I am using the sendmail function to send an email of the Excel document attached to a certain recipient. I was wondering if there was a way for it to prompt for another attachment. Here is my code:
ActiveWorkbook.SendMail Recipients:="Recipient Name", returnreceipt:="true", Subject:="Quote Request for Part #" + Range("A6")
I found a function called SendMailAttach, but I can't get it to work at all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top