Einlesen von Outlook-Kontakten mit VFP

Folgender Basiscode, der natürlich noch ausgestaltet werden kann, liest Outlook-Kontakte mit VFP ein:

Local fehler,myNameSpace,oContact,oContact

fehler=.t.
TRY
TRY
oOutlook = GETOBJECT(,“Outlook.Application“)
CATCH
oOutlook = CREATEOBJECT(„Outlook.Application“)
ENDTRY
CATCH && leider kein Outlook
fehler=.t.
ENDTRY

&& zusätzliche versionsabhängige Abfrage, 12 steht 2007, 11 etc für ältere, wenn man möchte
&& falls ein Problem mit der Standard-AppID gegeben ist.

IF fehler=.t.
fehler=.f.   && neuer Begin
TRY
TRY
oOutlook = GETOBJECT(,“Outlook.Application.12″)
CATCH
oOutlook = CREATEOBJECT(„Outlook.Application.12“)
ENDTRY
CATCH && leider kein Outlook
fehler=.t.
ENDTRY
ENDIF

IF fehler=.t.
MESSAGEBOX(‚Outlook ist nicht installiert oder wurde nicht erkannt‘,64,’Fehler‘)
return
ENDIF

myNameSpace =  oOutlook.GetNamespace(„mapi“)
oContact = myNameSpace.GetDefaultFolder[10]

For Each iContact In Thisform.oContact.Items
IF iContact.class=40 && 40=olContact
IF iContact.isConflict=.f.    && Falls Konflikt-Tag für Outlook-Eintrag gesetzt ist
Ihr Code  = iContact.firstname
= iContact.lastname
= iContact.CompanyName
= iContact.email1address
= iContact.HomeTelephoneNumber
= iContact.BusinessTelephoneNumber
= iContact.BusinessTelephoneNumber
= iContact.BusinessAddressCity
= iContact.BusinessAddressStreet
= iContact.BusinessAddressCity
= iContact.BusinessAddressCountry
= iContact.BusinessAddressPostalCode
= iContact.BusinessAddressState
= iContact.HomeAddressStreet
= iContact.HomeAddressCity
= iContact.HomeAddressCountry
= iContact.HomeAddressPostalCode
= iContact.HomeAddressState
= iContact.BusinessFaxNumber
= iContact.webpage
= iContact.birthday
ELSE
MESSAGEBOX(‚Konflikt: ‚+iContact.lastname,64,’Konflikt bei Adresse gefunden‘)
ENDIF
ENDIF
ENDFOR
Release oOutlook

Werbung & Infos:

HP Deal Days Angebote im HP Store (Juli 2024)


Extra HP Gutschein für Dich als mein Leser

Spare jetzt 10% beim Kauf eines Notebooks mit dem Gutschein HPMB10. Auch gültig für andere Produkte im HP Store und auch gültig für bereits rabattierte Angebote. Du kannst mit dem HP Gutschein also noch mal 10% extra sparen, acuh wenn ein Produkt bereits im Angebot ist.



Verwandte Themen: