function _setContact($mapimessage, $contact) { mapi_setprops($mapimessage, array(PR_MESSAGE_CLASS => "IPM.Contact")); // normalize email addresses if (isset($contact->email1address) && ($contact->email1address = $this->_extractEmailAddress($contact->email1address)) === false) { unset($contact->email1address); } if (isset($contact->email2address) && ($contact->email2address = $this->_extractEmailAddress($contact->email2address)) === false) { unset($contact->email2address); } if (isset($contact->email3address) && ($contact->email3address = $this->_extractEmailAddress($contact->email3address)) === false) { unset($contact->email3address); } $this->_setPropsInMAPI($mapimessage, $contact, $this->_contactmapping); // Set display name and subject to a combined value of firstname and lastname $cname = isset($contact->prefix) ? u2w($contact->prefix) . " " : ""; $cname .= u2w($contact->firstname); $cname .= isset($contact->middlename) ? " " . u2w($contact->middlename) : ""; $cname .= " " . u2w($contact->lastname); $cname .= isset($contact->suffix) ? " " . u2w($contact->suffix) : ""; $cname = trim($cname); //set contact specific mapi properties $props = array(); $nremails = array(); $abprovidertype = 0; if (isset($contact->email1address)) { $nremails[] = 0; $abprovidertype |= 1; $props[$this->_getPropIDFromString("PT_BINARY:{00062004-0000-0000-C000-000000000046}:0x8085")] = mapi_createoneoff($cname, "SMTP", $contact->email1address); //emailentryid $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8080")] = "{$cname} ({$contact->email1address})"; //displayname $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8082")] = "SMTP"; //emailadresstype $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8084")] = $contact->email1address; //original emailaddress } if (isset($contact->email2address)) { $nremails[] = 1; $abprovidertype |= 2; $props[$this->_getPropIDFromString("PT_BINARY:{00062004-0000-0000-C000-000000000046}:0x8095")] = mapi_createoneoff($cname, "SMTP", $contact->email2address); //emailentryid $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8090")] = "{$cname} ({$contact->email2address})"; //displayname $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8092")] = "SMTP"; //emailadresstype $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8094")] = $contact->email2address; //original emailaddress } if (isset($contact->email3address)) { $nremails[] = 2; $abprovidertype |= 4; $props[$this->_getPropIDFromString("PT_BINARY:{00062004-0000-0000-C000-000000000046}:0x80A5")] = mapi_createoneoff($cname, "SMTP", $contact->email3address); //emailentryid $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x80A0")] = "{$cname} ({$contact->email3address})"; //displayname $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x80A2")] = "SMTP"; //emailadresstype $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x80A4")] = $contact->email3address; //original emailaddress } $props[$this->_getPropIDFromString("PT_LONG:{00062004-0000-0000-C000-000000000046}:0x8029")] = $abprovidertype; $props[PR_DISPLAY_NAME] = $cname; $props[PR_SUBJECT] = $cname; //pda multiple e-mail addresses bug fix for the contact if (!empty($nremails)) { $props[$this->_getPropIDFromString("PT_MV_LONG:{00062004-0000-0000-C000-000000000046}:0x8028")] = $nremails; } //addresses' fix $homecity = $homecountry = $homepostalcode = $homestate = $homestreet = $homeaddress = ""; if (isset($contact->homecity)) { $props[PR_HOME_ADDRESS_CITY] = $homecity = u2w($contact->homecity); } if (isset($contact->homecountry)) { $props[PR_HOME_ADDRESS_COUNTRY] = $homecountry = u2w($contact->homecountry); } if (isset($contact->homepostalcode)) { $props[PR_HOME_ADDRESS_POSTAL_CODE] = $homepostalcode = u2w($contact->homepostalcode); } if (isset($contact->homestate)) { $props[PR_HOME_ADDRESS_STATE_OR_PROVINCE] = $homestate = u2w($contact->homestate); } if (isset($contact->homestreet)) { $props[PR_HOME_ADDRESS_STREET] = $homestreet = u2w($contact->homestreet); } $homeaddress = buildAddressString($homestreet, $homepostalcode, $homecity, $homestate, $homecountry); if ($homeaddress) { $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x801A")] = $homeaddress; } $businesscity = $businesscountry = $businesspostalcode = $businessstate = $businessstreet = $businessaddress = ""; if (isset($contact->businesscity)) { $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8046")] = $businesscity = u2w($contact->businesscity); } if (isset($contact->businesscountry)) { $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8049")] = $businesscountry = u2w($contact->businesscountry); } if (isset($contact->businesspostalcode)) { $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8048")] = $businesspostalcode = u2w($contact->businesspostalcode); } if (isset($contact->businessstate)) { $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8047")] = $businessstate = u2w($contact->businessstate); } if (isset($contact->businessstreet)) { $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8045")] = $businessstreet = u2w($contact->businessstreet); } $businessaddress = buildAddressString($businessstreet, $businesspostalcode, $businesscity, $businessstate, $businesscountry); if ($businessaddress) { $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x801B")] = $businessaddress; } $othercity = $othercountry = $otherpostalcode = $otherstate = $otherstreet = $otheraddress = ""; if (isset($contact->othercity)) { $props[PR_OTHER_ADDRESS_CITY] = $othercity = u2w($contact->othercity); } if (isset($contact->othercountry)) { $props[PR_OTHER_ADDRESS_COUNTRY] = $othercountry = u2w($contact->othercountry); } if (isset($contact->otherpostalcode)) { $props[PR_OTHER_ADDRESS_POSTAL_CODE] = $otherpostalcode = u2w($contact->otherpostalcode); } if (isset($contact->otherstate)) { $props[PR_OTHER_ADDRESS_STATE_OR_PROVINCE] = $otherstate = u2w($contact->otherstate); } if (isset($contact->otherstreet)) { $props[PR_OTHER_ADDRESS_STREET] = $otherstreet = u2w($contact->otherstreet); } $otheraddress = buildAddressString($otherstreet, $otherpostalcode, $othercity, $otherstate, $othercountry); if ($otheraddress) { $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x801C")] = $otheraddress; } $mailingadresstype = 0; if ($businessaddress) { $mailingadresstype = 2; } elseif ($homeaddress) { $mailingadresstype = 1; } elseif ($othercity) { $mailingadresstype = 3; } if ($mailingadresstype) { $props[$this->_getPropIDFromString("PT_LONG:{00062004-0000-0000-C000-000000000046}:0x8022")] = $mailingadresstype; switch ($mailingadresstype) { case 1: $this->_setMailingAdress($homestreet, $homepostalcode, $homecity, $homestate, $homecountry, $homeaddress, $props); break; case 2: $this->_setMailingAdress($businessstreet, $businesspostalcode, $businesscity, $businessstate, $businesscountry, $businessaddress, $props); break; case 3: $this->_setMailingAdress($otherstreet, $otherpostalcode, $othercity, $otherstate, $othercountry, $otheraddress, $props); break; } } if (isset($contact->picture)) { $picbinary = base64_decode($contact->picture); $picsize = strlen($picbinary); if ($picsize < MAX_EMBEDDED_SIZE) { //set the has picture property to true $haspic = $this->_getPropIDFromString("PT_BOOLEAN:{00062004-0000-0000-C000-000000000046}:0x8015"); $props[$haspic] = false; //check if contact has already got a picture. delete it first in that case //delete it also if it was removed on a mobile $picprops = mapi_getprops($mapimessage, array($haspic)); if (isset($picprops[$haspic]) && $picprops[$haspic]) { debugLog("Contact already has a picture. Delete it"); $attachtable = mapi_message_getattachmenttable($mapimessage); mapi_table_restrict($attachtable, getContactPicRestriction()); $rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM)); if (isset($rows) && is_array($rows)) { foreach ($rows as $row) { mapi_message_deleteattach($mapimessage, $row[PR_ATTACH_NUM]); } } } //only set picture if there's data in the request if ($picbinary !== false && $picsize > 0) { $props[$haspic] = true; $pic = mapi_message_createattach($mapimessage); // Set properties of the attachment $picprops = array(PR_ATTACH_LONG_FILENAME_A => "ContactPicture.jpg", PR_DISPLAY_NAME => "ContactPicture.jpg", 0x7fff000b => true, PR_ATTACHMENT_HIDDEN => false, PR_ATTACHMENT_FLAGS => 1, PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_EXTENSION_A => ".jpg", PR_ATTACH_NUM => 1, PR_ATTACH_SIZE => $picsize, PR_ATTACH_DATA_BIN => $picbinary); mapi_setprops($pic, $picprops); mapi_savechanges($pic); } } } mapi_setprops($mapimessage, $props); }
mergeStreet("business", $line[$csv_mapping["business_address_street2"]], $props, $properties); } if (isset($csv_mapping["business_address_street3"])) { mergeStreet("business", $line[$csv_mapping["business_address_street3"]], $props, $properties); } if (!isset($props[$properties["business_address"]])) { buildAddressString("business", $props[$properties["business_address_street"]], $props[$properties["business_address_postal_code"]], $props[$properties["business_address_city"]], $props[$properties["business_address_state"]], $props[$properties["business_address_country"]], $props, $properties); } if (isset($csv_mapping["other_address_street2"])) { mergeStreet("other", $line[$csv_mapping["other_address_street2"]], $props, $properties); } if (isset($csv_mapping["other_address_street3"])) { mergeStreet("other", $line[$csv_mapping["other_address_street3"]], $props, $properties); } if (!isset($props[$properties["other_address"]])) { buildAddressString("other", $props[$properties["other_address_street"]], $props[$properties["other_address_postal_code"]], $props[$properties["other_address_city"]], $props[$properties["other_address_state"]], $props[$properties["other_address_country"]], $props, $properties); } if (isset($props[$properties["business_address"]])) { $props[$properties["mailing_address"]] = 2; setMailingAdress($props[$properties["business_address_street"]], $props[$properties["business_address_postal_code"]], $props[$properties["business_address_city"]], $props[$properties["business_address_state"]], $props[$properties["business_address_country"]], $props[$properties["business_address"]], $props, $properties); } elseif (isset($props[$properties["home_address"]])) { $props[$properties["mailing_address"]] = 1; setMailingAdress($props[$properties["home_address_street"]], $props[$properties["home_address_postal_code"]], $props[$properties["home_address_city"]], $props[$properties["home_address_state"]], $props[$properties["home_address_country"]], $props[$properties["home_address"]], $props, $properties); } elseif (isset($props[$properties["other_address"]])) { $props[$properties["mailing_address"]] = 3; setMailingAdress($props[$properties["other_address_street"]], $props[$properties["other_address_postal_code"]], $props[$properties["other_address_city"]], $props[$properties["other_address_state"]], $props[$properties["other_address_country"]], $props[$properties["other_address"]], $props, $properties); } // if the display name is set, then it is a valid contact: save it to the folder if (isset($props[$properties["display_name"]])) { $props[$properties["message_class"]] = "IPM.Contact"; $props[$properties["icon_index"]] = "512";
function _setContact($mapimessage, $contact) { mapi_setprops($mapimessage, array(PR_MESSAGE_CLASS => "IPM.Contact")); $this->_setPropsInMAPI($mapimessage, $contact, $this->_contactmapping); // Set display name and subject to a combined value of firstname and lastname $cname = "" . u2w($contact->firstname . " " . $contact->lastname); //set contact specific mapi properties $props = array(); $nremails = array(); $abprovidertype = 0; if (isset($contact->email1address)) { $nremails[] = 0; $abprovidertype |= 1; $props[$this->_getPropIDFromString("PT_BINARY:{00062004-0000-0000-C000-000000000046}:0x8085")] = mapi_createoneoff($cname, "SMTP", $contact->email1address); //emailentryid $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8080")] = "{$cname} ({$contact->email1address})"; //displayname $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8082")] = "SMTP"; //emailadresstype $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8084")] = $contact->email1address; //original emailaddress } if (isset($contact->email2address)) { $nremails[] = 1; $abprovidertype |= 2; $props[$this->_getPropIDFromString("PT_BINARY:{00062004-0000-0000-C000-000000000046}:0x8095")] = mapi_createoneoff($cname, "SMTP", $contact->email2address); //emailentryid $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8090")] = "{$cname} ({$contact->email2address})"; //displayname $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8092")] = "SMTP"; //emailadresstype $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8094")] = $contact->email2address; //original emailaddress } if (isset($contact->email3address)) { $nremails[] = 2; $abprovidertype |= 4; $props[$this->_getPropIDFromString("PT_BINARY:{00062004-0000-0000-C000-000000000046}:0x80A5")] = mapi_createoneoff($cname, "SMTP", $contact->email3address); //emailentryid $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x80A0")] = "{$cname} ({$contact->email3address})"; //displayname $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x80A2")] = "SMTP"; //emailadresstype $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x80A4")] = $contact->email3address; //original emailaddress } $props[$this->_getPropIDFromString("PT_LONG:{00062004-0000-0000-C000-000000000046}:0x8029")] = $abprovidertype; $props[PR_DISPLAY_NAME] = $cname; $props[PR_SUBJECT] = $cname; //pda multiple e-mail addresses bug fix for the contact if (!empty($nremails)) { $props[$this->_getPropIDFromString("PT_MV_LONG:{00062004-0000-0000-C000-000000000046}:0x8028")] = $nremails; } //home address fix $homecity = $homestate = $homepostalcode = $homestate = $homestreet = ""; if (isset($contact->homecity)) { $props[PR_HOME_ADDRESS_CITY] = $homecity = u2w($contact->homecity); } if (isset($contact->homecountry)) { $props[PR_HOME_ADDRESS_COUNTRY] = $homestate = u2w($contact->homecountry); } if (isset($contact->homepostalcode)) { $props[PR_HOME_ADDRESS_POSTAL_CODE] = $homepostalcode = u2w($contact->homepostalcode); } if (isset($contact->homestate)) { $props[PR_HOME_ADDRESS_STATE_OR_PROVINCE] = $homestate = u2w($contact->homestate); } if (isset($contact->homestreet)) { $props[PR_HOME_ADDRESS_STREET] = $homestreet = u2w($contact->homestreet); } $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x801A")] = buildAddressString($homestreet, $homepostalcode, $homecity, $homestate, $homestate); mapi_setprops($mapimessage, $props); }
function import($store, $csv_file, $delete_old_items, $categories) { $folder = getContactsFolder($store); // open the csv file and start reading $fh = fopen($csv_file, "r"); if (!$fh) { trigger_error("Can't read CSV file \"" . $csv_file . "\".", E_USER_ERROR); } // Delete all existing items if requested. if ($delete_old_items) { mapi_folder_emptyfolder($folder, DEL_ASSOCIATED); printf("Old items deleted.\n"); } $properties = getProperties(); $properties = replaceStringPropertyTags($store, $properties); //composed properties which require more work $special_properties = getSpecialPropertyNames(); $csv_mapping = getMapping(); $i = 1; while (!feof($fh)) { $line = fgetcsv($fh, CSV_MAX_LENGTH, CSV_DELIMITER, CSV_ENCLOSURE); // print_r($line); if (!$line) { continue; } if ($i == 1 && defined('FIELD_NAMES') && FIELD_NAMES) { $i++; continue; } $propValues = array(); //set "simple" properties foreach ($csv_mapping as $property => $cnt) { if (!in_array($property, $special_properties)) { setProperty($property, $line[$csv_mapping[$property]], $propValues, $properties); } } // set display name if (isset($csv_mapping["display_name"]) && isset($line[$csv_mapping["display_name"]])) { $name = to_windows1252($line[$csv_mapping["display_name"]]); $propValues[$properties["display_name"]] = $propValues[$properties["subject"]] = $propValues[$properties["fileas"]] = $name; $propValues[$properties["fileas_selection"]] = -1; } else { $propValues[$properties["display_name"]] = $propValues[$properties["subject"]] = $propValues[$properties["fileas"]] = ""; if (isset($propValues[$properties["given_name"]])) { $propValues[$properties["display_name"]] .= $propValues[$properties["given_name"]]; $propValues[$properties["subject"]] .= $propValues[$properties["given_name"]]; } if (isset($propValues[$properties["surname"]])) { if (strlen($propValues[$properties["display_name"]]) > 0) { $propValues[$properties["display_name"]] .= " " . $propValues[$properties["surname"]]; $propValues[$properties["subject"]] .= " " . $propValues[$properties["surname"]]; } else { $propValues[$properties["display_name"]] .= $propValues[$properties["surname"]]; $propValues[$properties["subject"]] .= $propValues[$properties["surname"]]; } } if (isset($propValues[$properties["surname"]])) { $propValues[$properties["fileas"]] .= $propValues[$properties["surname"]]; } if (isset($propValues[$properties["given_name"]])) { if (strlen($propValues[$properties["fileas"]]) > 0) { $propValues[$properties["fileas"]] .= ", " . $propValues[$properties["given_name"]]; } else { $propValues[$properties["fileas"]] .= $propValues[$properties["given_name"]]; } } } $nremails = array(); $abprovidertype = 0; if (isset($csv_mapping["email_address_1"]) && isset($line[$csv_mapping["email_address_1"]])) { setEmailAddress($line[$csv_mapping["email_address_1"]], $propValues[$properties["display_name"]], 1, $propValues, $properties, $nremails, $abprovidertype); } if (isset($csv_mapping["email_address_2"]) && isset($line[$csv_mapping["email_address_2"]])) { setEmailAddress($line[$csv_mapping["email_address_2"]], $propValues[$properties["display_name"]], 2, $propValues, $properties, $nremails, $abprovidertype); } if (isset($csv_mapping["email_address_3"]) && isset($line[$csv_mapping["email_address_3"]])) { setEmailAddress($line[$csv_mapping["email_address_3"]], $propValues[$properties["display_name"]], 3, $propValues, $properties, $nremails, $abprovidertype); } if (!empty($nremails)) { $propValues[$properties["address_book_mv"]] = $nremails; } $propValues[$properties["address_book_long"]] = $abprovidertype; //set addresses if (isset($csv_mapping["home_address_street2"])) { mergeStreet("home", $line[$csv_mapping["home_address_street2"]], $propValues, $properties); } if (isset($csv_mapping["home_address_street3"])) { mergeStreet("home", $line[$csv_mapping["home_address_street3"]], $propValues, $properties); } if (!isset($propValues[$properties["home_address"]]) && isset($propValues[$properties["home_address_street"]]) && isset($propValues[$properties["home_address_postal_code"]]) && isset($propValues[$properties["home_address_city"]]) && isset($propValues[$properties["home_address_state"]]) && isset($propValues[$properties["home_address_country"]])) { buildAddressString("home", $propValues[$properties["home_address_street"]], $propValues[$properties["home_address_postal_code"]], $propValues[$properties["home_address_city"]], $propValues[$properties["home_address_state"]], $propValues[$properties["home_address_country"]], $propValues, $properties); } if (isset($csv_mapping["business_address_street2"])) { mergeStreet("business", $line[$csv_mapping["business_address_street2"]], $propValues, $properties); } if (isset($csv_mapping["business_address_street3"])) { mergeStreet("business", $line[$csv_mapping["business_address_street3"]], $propValues, $properties); } if (!isset($propValues[$properties["business_address"]]) && isset($propValues[$properties["business_address_street"]]) && isset($propValues[$properties["business_address_postal_code"]]) && isset($propValues[$properties["business_address_city"]]) && isset($propValues[$properties["business_address_state"]]) && isset($propValues[$properties["business_address_country"]])) { buildAddressString("business", $propValues[$properties["business_address_street"]], $propValues[$properties["business_address_postal_code"]], $propValues[$properties["business_address_city"]], $propValues[$properties["business_address_state"]], $propValues[$properties["business_address_country"]], $propValues, $properties); } if (isset($csv_mapping["other_address_street2"])) { mergeStreet("other", $line[$csv_mapping["other_address_street2"]], $propValues, $properties); } if (isset($csv_mapping["other_address_street3"])) { mergeStreet("other", $line[$csv_mapping["other_address_street3"]], $propValues, $properties); } if (!isset($propValues[$properties["other_address"]]) && isset($propValues[$properties["other_address_street"]]) && isset($propValues[$properties["other_address_postal_code"]]) && isset($propValues[$properties["other_address_city"]]) && isset($propValues[$properties["other_address_state"]]) && isset($propValues[$properties["other_address_country"]])) { buildAddressString("other", $propValues[$properties["other_address_street"]], $propValues[$properties["other_address_postal_code"]], $propValues[$properties["other_address_city"]], $propValues[$properties["other_address_state"]], $propValues[$properties["other_address_country"]], $propValues, $properties); } if (isset($propValues[$properties["home_address"]])) { $propValues[$properties["mailing_address"]] = 1; setMailingAdress($propValues[$properties["home_address_street"]], $propValues[$properties["home_address_postal_code"]], $propValues[$properties["home_address_city"]], $propValues[$properties["home_address_state"]], $propValues[$properties["home_address_country"]], $propValues[$properties["home_address"]], $propValues, $properties); } elseif (isset($propValues[$properties["business_address"]])) { $propValues[$properties["mailing_address"]] = 2; setMailingAdress($propValues[$properties["business_address_street"]], $propValues[$properties["business_address_postal_code"]], $propValues[$properties["business_address_city"]], $propValues[$properties["business_address_state"]], $propValues[$properties["business_address_country"]], $propValues[$properties["business_address"]], $propValues, $properties); } elseif (isset($propValues[$properties["other_address"]])) { $propValues[$properties["mailing_address"]] = 3; setMailingAdress($propValues[$properties["other_address_street"]], $propValues[$properties["other_address_postal_code"]], $propValues[$properties["other_address_city"]], $propValues[$properties["other_address_state"]], $propValues[$properties["other_address_country"]], $propValues[$properties["other_address"]], $propValues, $properties); } if (isset($categories) && !empty($categories)) { setProperty("categories", $categories, $propValues, $properties); } // if the display name is set, then it is a valid contact: save it to the folder if (isset($propValues[$properties["display_name"]])) { $propValues[$properties["message_class"]] = "IPM.Contact"; $propValues[$properties["icon_index"]] = "512"; $message = mapi_folder_createmessage($folder); mapi_setprops($message, $propValues); mapi_savechanges($message); printf("New contact added: \"%s\".\n", $propValues[$properties["display_name"]]); } $i++; } }