Automating Outlook from Other Applications

Outlook has a very powerful and complete object model. This enables you to perform many of the tasks you do every day in Outlook from other applications. You can write Microsoft Word macros that send email to colleagues, use Microsoft Access to send status messages from a database, and even use Visual Basic to create custom applications that do all sorts of things such as email inventory reports to managers and sales representatives. For example, the following code creates an Outlook message, enters recipient information, sets a subject and priority, adds an attachment, and sends the email message:

 Sub SendEmail()     Set objOutlook = CreateObject("Outlook.Application")     Set objNS = objOutlook.GetNamespace("MAPI")     Set objInbox = objNS.GetDefaultFolder(olFolderInbox)     Set objMessage = objInbox.CreateItem(olMailItem)     objMessage.To = "sally@email.com"     objMessage.Subject = "Inventory Report for Monday"     objMessage.Importance = olImportanceHigh     objMessage.Attachments.Add "c:\Reports\InventoryReport.xls"     objMessage.Send     Set objMessage = Nothing     Set objInbox = Nothing     Set objNS = Nothing     Set objOutlook = Nothing End Sub 

You can also create appointment items, contacts, tasks, journal entries, and notes from external applications. The only potential problem with automating Outlook from other applications arises from the Outlook security features that block certain segments of the Outlook object model. In particular, sending messages through code and accessing certain properties of a contact item can cause the object model guard to pop up messages that can often confuse or irritate users. You can either use a third-party tool such as Redemption, or deploy the Exchange Administrative Options package to configure the object model guard.

For more information about the Exchange Administrative Options package, see "Outlook Administration", p. 916.




Special Edition Using Microsoft Office Outlook 2003
Special Edition Using Microsoft Office Outlook 2003
ISBN: 0789729563
EAN: 2147483647
Year: 2003
Pages: 426

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