Chapter 11. Programming Outlook Email

     

In this chapter

  • Specifying, copying, moving, and deleting email folders.

  • Determining the sender's name and address, the subject and body, and other email message data.

  • Displaying, closing, moving, and deleting email messages.

  • Sending new messages as well as replying to and forwarding received messages.

  • Adding, saving, and removing email attachments.

  • Working with Outlook's email capabilities from other applications.

Not many people know it, but Microsoft Outlook also incorporates VBA, so you can create Outlook-based VBA macros and applications. Outlook itself is a big program, so you can imagine that the Outlook object model is huge, with dozens of objects and untold numbers of properties, methods , and events. The proverbial space limitations prevent me from examining this model in detail, so this chapter just takes you through those objects related to Outlook's email features.

Although Outlook has an Application object at the top of its hierarchy, your Outlook programming will rarely need to use it. Instead, your programs will always begin with the NameSpace object. The oddly named object acts as a kind of top-level object for a data source , which, as its name implies, is a kind of container for data. The NameSpace object enables you to log in to the source, access the data, and then log out. In Outlook's case, the only supported data source is something called MAPI ”Mail Application Programming Interface ”which represents the data in an Outlook personal folders store (a .pst file).

After you've started Outlook, you've already logged in, so your code can simply refer to the current session as the namespace. To do that, you use the default Outlook object, which is called ThisOutlookSession . Use this object's Session property to get the NameSpace object:

 Dim ns As NameSpace Set ns = ThisOutlookSession.Session 


Absolute Beginner's Guide to VBA
Absolute Beginners Guide to VBA
ISBN: 0789730766
EAN: 2147483647
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net