Archive of Mr Excel Message Board


Back to Other Office and Excel archive index
Back to archive home

Using Sendmail command to send a high priority email

Posted by Michael S Thompson on November 15, 2001 10:51 AM
Hello all,

Does anybody know a way to use the ActiveWorkbook.SendMail method in Excel VBA to send the workbook via email with high priority? Otherwise, how would you include the current workbook as an attachment in a MAPI session (I believe you can send an MAPI email has high priority).

Thanx,

Shane T


Re: Using Sendmail command to send a high priority email

Posted by Tom Morales on November 15, 2001 11:55 AM
Shane -
I don't think the sendmail method will do it for you, so your degree of difficulty is jacked up a notch. A potential opportunity to learn...

You'll have to load in and use Outlook's object library to get where you want to go. eg, first, in your Excel Macro, add the libraries you'll need:
On Error Resume Next
'adding VBE object library:
ActiveWorkbook.VBProject.References.AddFromGuid "{0002E157-0000-0000-C000-000000000046}", 5, 0
'Adding outlook object library:
Application.VBE.ActiveVBProject.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 8, 0
On Error GoTo 0

Then, start an Outlook session, eg...

Set myOlApp = CreateObject("Outlook.Application")
Set olMAPI = myOlApp.GetNamespace("MAPI")

Have the macro save your Excel file, create a mailitem, attach the saved file, define a priority, and send the mailitem.
For more guidance, look at Outlook's Send method, mailitem object, and mailitem's Importance property.

I think I've given you the main compass points. It shouldn't be too difficult to cobble together some code. Good Luck.

Tom


Re: Using Sendmail command to send a high priority email

Posted by Shane T on November 15, 2001 1:29 PM
Thank you, that is along the line that I was thinking.


This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.