MS Outlook contacts to MS Access database table to get in,
MS Outlook contacts to an Access data base?
MS Outlook contacts to MS Access database table to get in,
MS Outlook contacts to an Access data base?
I guessnosolution
Is there a solution?
I want to sync to Outlook from Access.
Sample added. I hope to describe
Please attach full file
What do you want to sync?????
Please write in your field by EN
What is the full file to add?
The sample file at the project stage
MS Outlook contacts to MS Access database
I do not know English.
would translate to google.translate.com Sorry for errors in translation.
I found the following codes to get the error message.
How will the Solution?
export Outlook items to Access
import Outlook items from AccessCode:Sub ImportContactsFromOutlook() ' This code is based in Microsoft Access. ' Set up DAO objects (uses existing "tblContacts" table) Dim rst As DAO.Recordset Set rst = CurrentDb.OpenRecordset("tblContacts") ' Set up Outlook objects. Dim ol As New Outlook.Application Dim olns As Outlook.Namespace Dim cf As Outlook.MAPIFolder Dim c As Outlook.ContactItem Dim objItems As Outlook.Items Dim Prop As Outlook.UserProperty Set olns = ol.GetNamespace("MAPI") Set cf = olns.GetDefaultFolder(olFolderContacts) Set objItems = cf.Items iNumContacts = objItems.Count If iNumContacts <> 0 Then For i = 1 To iNumContacts If TypeName(objItems(i)) = "ContactItem" Then Set c = objItems(i) rst.AddNew rst!FirstName = c.FirstName rst!LastName = c.LastName rst!Address = c.BusinessAddressStreet rst!City = c.BusinessAddressCity rst!State = c.BusinessAddressState rst!Zip_Code = c.BusinessAddressPostalCode ' Custom Outlook properties would look like this: ' rst!AccessFieldName = c.UserProperties("OutlookPropertyName") rst.Update End If Next i rst.Close MsgBox "Finished." Else MsgBox "No contacts to export." End If End Sub
Code:Sub ExportAccessContactsToOutlook() ' Set up DAO Objects. Dim oDataBase As DAO.Database Dim rst As DAO.Recordset Set oDataBase = OpenDatabase _ ("c:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb") Set rst = oDataBase.OpenRecordset("Customers") ' Set up Outlook Objects. Dim ol As New Outlook.Application Dim olns As Outlook.Namespace Dim cf As Outlook.MAPIFolder Dim c As Outlook.ContactItem Dim Prop As Outlook.UserProperty Set olns = ol.GetNamespace("MAPI") Set cf = olns.GetDefaultFolder(olFolderContacts) With rst .MoveFirst ' Loop through the Microsoft 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 second user property (UserField2). Set Prop = c.UserProperties.Add("UserField2", olText) ' Set its value and so on.... If ![Region] <> "" Then Prop = ![Region] ' Save and close the contact. c.Save c.Close .MoveNext Loop End With End Sub
Do not have one?
The difficulty is that ....
I need too .....
Everyone have any idea ????
Problem solved
Set up a reference to Outlook in the VBA editor-Tools-References?
I found the following codes to get the error message.
How will the Solution?
export Outlook items to Access
import Outlook items from AccessCode:Sub ImportContactsFromOutlook() ' This code is based in Microsoft Access. ' Set up DAO objects (uses existing "tblContacts" table) Dim rst As DAO.Recordset Set rst = CurrentDb.OpenRecordset("tblContacts") ' Set up Outlook objects. Dim ol As New Outlook.Application Dim olns As Outlook.Namespace Dim cf As Outlook.MAPIFolder Dim c As Outlook.ContactItem Dim objItems As Outlook.Items Dim Prop As Outlook.UserProperty Set olns = ol.GetNamespace("MAPI") Set cf = olns.GetDefaultFolder(olFolderContacts) Set objItems = cf.Items iNumContacts = objItems.Count If iNumContacts <> 0 Then For i = 1 To iNumContacts If TypeName(objItems(i)) = "ContactItem" Then Set c = objItems(i) rst.AddNew rst!FirstName = c.FirstName rst!LastName = c.LastName rst!Address = c.BusinessAddressStreet rst!City = c.BusinessAddressCity rst!State = c.BusinessAddressState rst!Zip_Code = c.BusinessAddressPostalCode ' Custom Outlook properties would look like this: ' rst!AccessFieldName = c.UserProperties("OutlookPropertyName") rst.Update End If Next i rst.Close MsgBox "Finished." Else MsgBox "No contacts to export." End If End Sub
Code:Sub ExportAccessContactsToOutlook() ' Set up DAO Objects. Dim oDataBase As DAO.Database Dim rst As DAO.Recordset Set oDataBase = OpenDatabase _ ("c:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb") Set rst = oDataBase.OpenRecordset("Customers") ' Set up Outlook Objects. Dim ol As New Outlook.Application Dim olns As Outlook.Namespace Dim cf As Outlook.MAPIFolder Dim c As Outlook.ContactItem Dim Prop As Outlook.UserProperty Set olns = ol.GetNamespace("MAPI") Set cf = olns.GetDefaultFolder(olFolderContacts) With rst .MoveFirst ' Loop through the Microsoft 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 second user property (UserField2). Set Prop = c.UserProperties.Add("UserField2", olText) ' Set its value and so on.... If ![Region] <> "" Then Prop = ![Region] ' Save and close the contact. c.Save c.Close .MoveNext Loop End With End Sub
Could you upload file for demo?
Limited sample of the names I added to my table to be Turkish.
Is it possible to export from Outlook, and the sample table to add here.
I'd be happy to
Sample download
http://www.dosyayukle.in/do.php?id=3306