' First, connect to the Outlook application object. This is like the Excel application object, but it's for Outlook instead of Excel. After
' this, ool contains all the other stuff you need to interact with Outlook.
Set ool = GetObject(, "Outlook.Application")
' Now start a new email:
Set oeml = ool.CreateItem(0) '0 indicates an email rather than one of the other obects Outlook can deal with, like a task or a
'calendar appointment. From now on we'll be using the oeml object.
' If your Outlook client has more than one email account — maybe you fetch your business email there as well as personal — you may need to pick
' the account you want to use. If you have just the one account, you don't need this statement.
Set oeml.SendUsingAccount = ool.Session.Accounts.Item("my.email@gmail.com")
' Set some of the email's fields:
oeml.To = <AddrTo> 'or more than one address
oeml.cC = <AddrCc>
oeml.Subject = <Subj text>
' I'm not real confident about Outlook programming, but I think the Inspector is a part of Outlook that displays an email. This statement is
' needed either to make the email visible on your screen, or maybe just to bring it into the foreground on top of the Excel workbook you
' were working with. You should experiment with leaving out this statement to see what happens.
oeml.GetInspector.Activate
' I gather you want to add an attachment. The program I'm copying from doesn't do that, but I'm pretty sure it works like this (for example):
oeml.attachments.add "C:\path\filename.txt"