OL97: How to Programmatically Import Outlook Items from AccessLast reviewed: March 2, 1998Article ID: Q170320 |
The information in this article applies to:
SUMMARYThis article provides an overview and example code for creating Microsoft Outlook 97 Contacts from information stored in a Microsoft Access 97 database. The sample code below would be run from an Access 97 global module and provides a starting point for the development of a complete solution. NOTE: There is also an overview and separate code example available on the Microsoft web site at the following location. It is the first example in the whitepaper.
http://www.microsoft.com/officedev/articles/sampauto.htmNOTE: Because the Microsoft Web site is constantly updated, the site address may change without notice. If this occurs, link to the Microsoft home page at the following address:
http://www.microsoft.com/ MORE INFORMATIONOutlook 97's Import and Export feature does not allow you to import or export information in user-defined fields (or properties). To import information into these fields, you need to create a programming solution that uses Automation to convert the information. The following example code specifically converts information from Microsoft Access into newly created Outlook Contacts, using Data Access Objects (DAO 3.5). With modifications, you can use this code as a basis for creating other types of Outlook items, such as appointments, notes, tasks, and such. Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/default.asp Programming Considerations
Article-ID: Q169750 Title : OL97: How to Programmatically Resolve a Contact's E-mail Address Example Code
Sub ExportAccessContactsToOutlook() 'Set up DAO Objects: Dim oDataBase As Object Dim rst As Object Set oDataBase = OpenDatabase _ ("c:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb") Set rst = oDataBase.OpenRecordset("Customers") 'Set up Outlook Objects: Dim olns As Object ' Outlook Namespace Dim cf As Object ' Contact folder Dim c As Object ' Contact Item Dim Prop As Object ' User property Dim ol As New Outlook.Application Set olns = ol.GetNamespace("MAPI") Set cf = olns.GetDefaultFolder(olFolderContacts) With rst .MoveFirst ' Loop through the Access records Do While Not .EOF ' Create a new Contact item Set c = ol.CreateItem(olContactItem) ' Specify which Outlook form to use: ' Change "IPM.Contact" to "IPM.Contact.<formname>" if you've ' created a custom Contact form in Outlook. c.MessageClass = "IPM.Contact" ' Create all built-in Outlook fields If ![CompanyName] <> "" Then c.CompanyName = ![CompanyName] If ![ContactName] <> "" Then c.FullName = ![ContactName] ' Create the first user property (UserField1) Set Prop = c.UserProperties.Add("UserField1", olText) ' Set its value If ![CustomerID] <> "" Then Prop = ![CustomerID] ' Create the first user property (UserField2) Set Prop = c.UserProperties.Add("UserField2", olText) ' Set it's value, and so on.... If ![Region] <> "" Then Prop = ![Region] ' Save the contact c.Save .MoveNext Loop End With End Sub REFERENCESFor more information about creating solutions with Microsoft Outlook 97, please see the following articles in the Microsoft Knowledge Base:
Article-ID: Q166368 Title : OL97: How to Get Help Programming with Outlook Article-ID: Q170783 Title : OL97: Q&A: Questions about Customizing or Programming Outlook |
Additional query words: OutSol OutSol97
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |