Example Code for sending mail from Excel
The code is tested in Outlook Express, Windows Mail, Windows Live Mail and Outlook and It may
or may not work
with other email clients. All code on this page will work in Excel
97-2010 or Excel 2000-2010.
If you use Lotus Notes click here : http://www.rondebruin.nl/notes.htm
If you use Apple Mail or Outlook 2011 on a Mac click here : http://www.rondebruin.nl/mac.htm#Mail
There are four Microsoft mail programs:
Microsoft Outlook, Outlook Express, Windows Mail (replace Outlook Express in Vista) and Windows Live Mail. Microsoft Outlook is a part of Microsoft Office and Outlook Express and Windows Mail are a part of the operating system.
Note: Windows Mail is removed from Windows 7, as a alternitive you can install Windows Live Mail.
Windows Live Mail is a free program of Microsoft that you can download here :
http://download.live.com/wlmail
Important: if you set a Windows Live mail version before Windows Live mail 2011 as your default mail mail program it is possible that if you want to mail from Excel you get a General mail failure because it isn’t fully MAPI-qualified like Windows Mail or Outlook. Note: Microsoft fixed this problem in Windows Live mail 2011.
But the code in in the SendMail section is working correct in every version of Windows Live mail.
But if you want to send directly with the mail address in the code the address must be in your contacts.
The code in the "SendMail method" section of this tips page are working with all four the mail programs.
The code in the "Outlook object model (attachment and body)" 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 two sections. A good alternative for the Outlook object model code on this page is the
CDO for Win 2000 code on my CDO page (no security warnings)
Add-ins and Worksheet Templates
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)
Or use a worksheet template from this page
Mail Worksheet Templates
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
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
Send a mail when a cell reaches a certain value Updated
Send mail with link to workbook
Other Tips
Sending mail from Excel with CDO (no security warnings) TIP
Use the Account you want in mail macro in Excel/Outlook 2007-2010
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
Links to information and articles about mailing in Excel
Send a range in the body with Outlook Express
My mail articles on MSDN
Using VBA in Excel to Send Workbooks and Ranges through E-Mail with Outlook (Part 1 of 2)
Using VBA in Excel to Send Workbooks and Ranges through E-Mail with Outlook (Part 2 of 2)
Creating and Sending PDF Files from Excel 2007 and Excel 2010
Working with Excel Workbooks and Worksheets in E-Mail (Excel 97-2010)
Different Ways to Take Advantage of the E-mail Features of Excel (Excel 97-2003)
If you use Lotus Notes click here : http://www.rondebruin.nl/notes.htm
If you use Apple Mail or Outlook 2011 on a Mac click here : http://www.rondebruin.nl/mac.htm#Mail
There are four Microsoft mail programs:
Microsoft Outlook, Outlook Express, Windows Mail (replace Outlook Express in Vista) and Windows Live Mail. Microsoft Outlook is a part of Microsoft Office and Outlook Express and Windows Mail are a part of the operating system.
Note: Windows Mail is removed from Windows 7, as a alternitive you can install Windows Live Mail.
Windows Live Mail is a free program of Microsoft that you can download here :
http://download.live.com/wlmail
Important: if you set a Windows Live mail version before Windows Live mail 2011 as your default mail mail program it is possible that if you want to mail from Excel you get a General mail failure because it isn’t fully MAPI-qualified like Windows Mail or Outlook. Note: Microsoft fixed this problem in Windows Live mail 2011.
But the code in in the SendMail section is working correct in every version of Windows Live mail.
But if you want to send directly with the mail address in the code the address must be in your contacts.
The code in the "SendMail method" section of this tips page are working with all four the mail programs.
The code in the "Outlook object model (attachment and body)" 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 two sections. A good alternative for the Outlook object model code on this page is the
CDO for Win 2000 code on my CDO page (no security warnings)
Add-ins and Worksheet Templates
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)
Or use a worksheet template from this page
Mail Worksheet Templates
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
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
Send a mail when a cell reaches a certain value Updated
Send mail with link to workbook
Other Tips
Sending mail from Excel with CDO (no security warnings) TIP
Use the Account you want in mail macro in Excel/Outlook 2007-2010
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
Links to information and articles about mailing in Excel
Send a range in the body with Outlook Express
My mail articles on MSDN
Using VBA in Excel to Send Workbooks and Ranges through E-Mail with Outlook (Part 1 of 2)
Using VBA in Excel to Send Workbooks and Ranges through E-Mail with Outlook (Part 2 of 2)
Creating and Sending PDF Files from Excel 2007 and Excel 2010
Working with Excel Workbooks and Worksheets in E-Mail (Excel 97-2010)
Different Ways to Take Advantage of the E-mail Features of Excel (Excel 97-2003)