MS Outlook 98 – Sending Email and Attachments

By | 2002-06-01

This code will send email through MS Outlook 98, (or the most current version on your computer),
using MS Excel 7.0 or higher.

Original Author: Michelle Grey

Assumptions

You must have MS Outlook and MS Excel 7.0 or higher.

Returns

This code will open MS Outlook and open a new email message, insert the recipients email address,
the attachment, the subject of the message, and send the email.
**Note: This is with the aid of using John O’Donald’s code and revising it to work for me.

Side Effects


Note: The MailItem.Send line may not work in Excel 97.

Code


Sub EmailFromOutlookInExcel() 'macro name
  Set myOlApp = CreateObject("Outlook.Application") 'opens Outlook
  Set MailItem = myOlApp.CreateItem(olMailItem)   ' opens new email
  Set myRecipient = MailItem.Recipients.Add("recipient@company.com")  'inserts recipient's email address
  MailItem.Subject = "Subject of message goes here"   'subject of the email
  Set myAttachments = MailItem.Attachments.Add("C:foldernamefilename")  'Path to Attachments
'Repeat this line if there are more Attachments
  MailItem.Send  'sends the email
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.