Example Code for sending mail from Excel
The code is tested in Outlook Express, Windows Mail and Outlook and It may
or may not work
with other email clients. All code on this page will also work in Excel 2007.
There are three Microsoft mail programs:
Microsoft Outlook, Outlook Express, Windows Mail (new in Vista, replace Outlook Express).
Microsoft Outlook is a part of Microsoft Office and Outlook Express and Windows Mail are a part of the operating system.
The code in the links in the first section of this tips page are working with all three programs
and uses the SendMail Method. The code in the second and third section of this tips page are only
working with Microsoft Outlook. Because there is an object model for Outlook you have much more
options when you use the code in this section.
A good alternative for the Outlook object model code is CDO for Win 2000
on my CDO page (no security warnings)
If you want it easy without using VBA code then try one of the Add-ins on this page
Mail Add-ins for Excel (Free and very easy to use)
New: Outlook Mail Worksheet Template for Excel 2007-2010
http://www.rondebruin.nl/mail/outlooksheettemplate.htm
New: Outlook Mail PDF Worksheet Template for Excel 2007-2010
http://www.rondebruin.nl/mail/outlooksheettemplatepdf.htm
SendMail method Download Example Workbook 1
Mail the whole workbook
Mail one sheet
Mail more then one sheet
Mail Range or Selection
Mail every worksheet with address in A1
Mail a row or rows to each person in a range
Outlook object model (attachment) Download Example Workbook 2
Mail the whole workbook
Mail one sheet
Mail more then one sheet
Mail Range or Selection
Mail every worksheet with address in A1
Mail a different file(s) to each person in a range
Mail chart or chart sheet as picture
Mail a row or rows to each person in a range
Mail Sheet, Sheets, Range or workbook as PDF in Excel 2007 New
Insert Outlook Signature in mail
Zip the Active Workbook and mail it with Outlook
Outlook object model (body) Download Example Workbook 3
Mail one worksheet in the body of the mail
Mail Range/Selection in the body of the mail
Mail selection, range or worksheet in the body of a mail with MailEnvelope
Mail a small message
Mail a message to each person in a range
Mail every worksheet with address in A1 (Body)
Insert Outlook Signature in mail
Mail a row to each person in a range
Mail a row or rows to each person in a range New
Other Tips
Sending mail from Excel with CDO (no security warnings) TIP
Use the Account you want in mail macro in Excel/Outlook 2007 New
Save E-mail attachments to folder
Security (Prevent displaying the dialog to Send or not Send)
Problems with Mailing from Excel
Convert Excel data to Outlook Contacts New
Links to information and articles about mailing in Excel
Send a mail when a cell reaches a certain value
Send a range in the body with Outlook Express
with other email clients. All code on this page will also work in Excel 2007.
There are three Microsoft mail programs:
Microsoft Outlook, Outlook Express, Windows Mail (new in Vista, replace Outlook Express).
Microsoft Outlook is a part of Microsoft Office and Outlook Express and Windows Mail are a part of the operating system.
The code in the links in the first section of this tips page are working with all three programs
and uses the SendMail Method. The code in the second and third section of this tips page are only
working with Microsoft Outlook. Because there is an object model for Outlook you have much more
options when you use the code in this section.
A good alternative for the Outlook object model code is CDO for Win 2000
on my CDO page (no security warnings)
If you want it easy without using VBA code then try one of the Add-ins on this page
Mail Add-ins for Excel (Free and very easy to use)
New: Outlook Mail Worksheet Template for Excel 2007-2010
http://www.rondebruin.nl/mail/outlooksheettemplate.htm
New: Outlook Mail PDF Worksheet Template for Excel 2007-2010
http://www.rondebruin.nl/mail/outlooksheettemplatepdf.htm
SendMail method Download Example Workbook 1
Mail the whole workbook
Mail one sheet
Mail more then one sheet
Mail Range or Selection
Mail every worksheet with address in A1
Mail a row or rows to each person in a range
Outlook object model (attachment) Download Example Workbook 2
Mail the whole workbook
Mail one sheet
Mail more then one sheet
Mail Range or Selection
Mail every worksheet with address in A1
Mail a different file(s) to each person in a range
Mail chart or chart sheet as picture
Mail a row or rows to each person in a range
Mail Sheet, Sheets, Range or workbook as PDF in Excel 2007 New
Insert Outlook Signature in mail
Zip the Active Workbook and mail it with Outlook
Outlook object model (body) Download Example Workbook 3
Mail one worksheet in the body of the mail
Mail Range/Selection in the body of the mail
Mail selection, range or worksheet in the body of a mail with MailEnvelope
Mail a small message
Mail a message to each person in a range
Mail every worksheet with address in A1 (Body)
Insert Outlook Signature in mail
Mail a row to each person in a range
Mail a row or rows to each person in a range New
Other Tips
Sending mail from Excel with CDO (no security warnings) TIP
Use the Account you want in mail macro in Excel/Outlook 2007 New
Save E-mail attachments to folder
Security (Prevent displaying the dialog to Send or not Send)
Problems with Mailing from Excel
Convert Excel data to Outlook Contacts New
Links to information and articles about mailing in Excel
Send a mail when a cell reaches a certain value
Send a range in the body with Outlook Express