vba - Update contacts in contact folder from GAL -
i trying update contact list gal.
the system updating contact list macro deletes contacts in given folder adds contacts gal contacts date. creates problem if add home address or personal phone contact lose them once update contact list.
i have macro in gal contacts match specific requirement (our office location).
now tricky part
if contact (based on full name) in contact list want update company dedicated fields, (such as: company name, position , on) leave other fields are.
if contact not in contact list: add - works
if contact in contact list has not been matched gal (means person left company) delete company dedicated fields (same in 1).
my code (adds contact based on location)
sub getallgalmembers() dim olapp outlook.application dim olns outlook.namespace dim olgal outlook.addresslist dim olentry outlook.addressentries dim olmember outlook.addressentry dim objitem outlook.contactitem dim mycontacts outlook.mapifolder dim myfolder mapifolder dim myitems items set mysession = new outlook.application set myns = mysession.getnamespace("mapi") set mycontacts = myns.getdefaultfolder(olfoldercontacts) set myfolder = mycontacts.folders("prague") set myitems = myfolder.items set olapp = outlook.application set olns = olapp.getnamespace("mapi") set olgal = olns.getglobaladdresslist() set olentry = olgal.addressentries on error resume next ' loop through dist list , extract members dim long = 1 olentry.count set olmember = olentry.item(i) if olmember.addressentryusertype = olexchangeuseraddressentry strlocation = olmember.getexchangeuser.officelocation if strlocation = "prg" set objitem = olapp.createitem(olcontactitem) objitem .firstname = olmember.getexchangeuser.firstname .last = olmember.getexchangeuser.lastname .fullname = olmember.getexchangeuser.name .email1address = olmember.getexchangeuser.primarysmtpaddress .businesstelephonenumber = olmember.getexchangeuser.businesstelephonenumber .mobiletelephonenumber = olmember.getexchangeuser.mobiletelephonenumber .companyname = olmember.getexchangeuser.companyname .email2displayname = olmember.getexchangeuser.displaytype .save end end if end if next end sub
look @ other side, match entries in contact list gal https://msdn.microsoft.com/en-us/library/office/ff869448.aspx.
set myaddressentry = myaddresslist.addressentries(index)
this accepts string instead of index pass string see in (display) name match or close entry if there no match.
Comments
Post a Comment