Hi,
Is there any way to read and write Outlook contacts from Xojo?
Thanks
Hi,
Is there any way to read and write Outlook contacts from Xojo?
Thanks
Maybe this one is helpful: AddressBook Object for Windows? Outlook Import/Export? - #7 by John_Hansen
The following Code by @John_Hansen works just fine here for reading them, using no Plugins and Office LTSC.
Var myOlApp As OLEObject
Var myNamespace As OLEObject
Var myContacts As OLEObject
Var myItems As OLEObject
Var myItem As OLEObject
Var nItems As Integer
Var outText As String
// Enumeration See: http://msdn.microsoft.com/en-us/library/office/bb208072%28v=office.12%29.aspx
Const olFolderContacts = 10
myOlApp = New OLEObject( "Outlook.Application" )
myNamespace = myOlApp.GetNamespace( "MAPI" )
myContacts = myNameSpace.GetDefaultFolder( olFolderContacts )
myItems = myContacts.Items
nItems = myItems.count
outText = "Total number of contacts: " + str( nItems ) + EndOfLine.Windows + EndOfLine.Windows
If nItems > 5 Then nItems = 5 // in this case we only want to show max 5 contacts
For i As Integer = 1 To nItems
myItem = myContacts.Items( i )
outText = outText + "Full Name: " + myItem.FullName + EndOfLine.Windows _
+ "Company: " + myItem.CompanyName + EndOfLine.Windows _
+ "Job Title: " + myItem.JobTitle + EndOfLine.Windows _
+ "E-mail: " + myItem.Email1Address + EndOfLine.Windows _
+ "Display as: " + myItem.Email1DisplayName + EndOfLine.Windows + EndOfLine.Windows
// Contact Item info: msdn.microsoft.com/en-us/library/office/aa210907%28v=office.11%29.aspx
Next
Msgbox outText
myOlApp = Nil
Exception err As oleexception
msgbox err.message
Like this: Outlook Contact Examples for Xojo Plugin . The Chilkat plugin is a paid plugin. Some users here on the forum will tell you that they don’t like the developer. But the plugin itself is very good.
Thanks
It works perfectly for reading Outlook contacts, but I don’t see a way to add contacts.
I have no experience with OLEObjects.
There will guaranteed be example code for VBA and/or VB6 - just research and adapt to Xojo and reference the above already provided to you code as a guide to approach.