Send Mail
Table 21-1 lists the different ways to send mail within Excel.
Table 21-1. Sending mail from Excel
|
To |
Use |
Notes |
|---|---|---|
|
Compose a text email message |
The |
Doesn’t support attachments. |
|
Compose an email with an attached workbook |
The |
User must fill in addresses and subject on the message. |
|
Send a workbook |
The |
Doesn’t display message before send; shows security warning. |
|
Send a worksheet or chart |
The |
Unlike |
|
Collect review comments |
The |
Allows you to link to a shared workbook for collecting comments. |
|
Route for approval |
The |
Routes to addresses in sequence. |
I’ve used FollowHyperlink technique a few times already in this book. In case you missed it, here’s short sample:
Sub SendTextMail( )
ThisWorkbook.FollowHyperlink "mailto:someone@microsoft.com" & _
"?Subject=Test message.&Body=The message goes here..."
End SubThe mailto: protocol starts the user’s default email client and creates a new message. It’s up to the user to send the message, so there are no real security hurdles to this approach. You can’t attach files using mailto: however. To create a quick email with the current workbook attached, use the Dialogs method as shown here:
Sub SendAsAttachment( ) Application.Dialogs(xlDialogSendMail).Show ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access