יצירת ושמירת אנשי קשר של Outlook ב-Python

Aspose.Email - יצירת ושימור אנשי קשר של Outlook

כדי ליצור ולשמור אנשי קשר של Outlook באמצעות Aspose.Email Java for Python, השתמש בקוד הבא.

קוד Python

contact = self.MapiContact()

\# הגדר תכונות שונות של פריט קשר זה.

\# הגדר תכונות שם באמצעות MapiContactNamePropertySet

name_prop_set = self.MapiContactNamePropertySet()

name_prop_set.setSurname(\"Mellissa\")

name_prop_set.setGivenName(\"MacBeth\")

contact.setNameInfo(name_prop_set)

\# הגדר תכונות מקצועיות באמצעות MapiContactProfessionalPropertySet

prof_prop_set = self.MapiContactProfessionalPropertySet()

prof_prop_set.setTitle(\"Account Representative\")

prof_prop_set.setCompanyName(\"Contoso Ltd.\")

prof_prop_set.setOfficeLocation(\"36/2529\")

contact.setProfessionalInfo(prof_prop_set)

\# טלפונים

telephone = self.MapiContactTelephonePropertySet()

telephone.setAssistantTelephoneNumber(\"(831) 758-7214\")

telephone.setBusiness2TelephoneNumber(\"(831) 759-2518\")

telephone.setBusinessTelephoneNumber(\"(831) 758-7285\")

telephone.setCallbackTelephoneNumber(\"(831) 758-7321 (After hours\")

telephone.setCarTelephoneNumber(\"(831) 758-7201\")

telephone.setCompanyMainTelephoneNumber(\"(831) 758-7368\")

telephone.setHome2TelephoneNumber(\"(831) 758-7256\")

telephone.setHomeTelephoneNumber(\"(831) 758-7257\")

telephone.setIsdnNumber(\"(831) 758-7381\")

telephone.setMobileTelephoneNumber(\"(831) 758-7368\")

telephone.setOtherTelephoneNumber(\"(831) 758-7201\")

telephone.setPagerTelephoneNumber(\"(831) 758-7368\")

telephone.setPrimaryTelephoneNumber(\"(831) 758-7334\")

telephone.setRadioTelephoneNumber(\"(831) 758-7234\")

telephone.setTelexNumber(\"(831) 758-7408\")

telephone.setTtyTddPhoneNumber(\"(800) 806-4474\")

contact.setTelephones(telephone)

\# הגדר כתובת פיזית באמצעות MapiContactPhysicalAddress ו-MapiContactPhysicalAddressPropertySet

phys_addrss = self.MapiContactPhysicalAddress()

phys_addrss.setPostOfficeBox(\"144 Hitchcock Rd, Salinas, CA 93908\")

phys_addr_prop_set = self.MapiContactPhysicalAddressPropertySet()

phys_addr_prop_set.setWorkAddress(phys_addrss)

contact.setPhysicalAddresses(phys_addr_prop_set)

\# הגדר מידע אימייל באמצעות MapiContactElectronicAddress ו-MapiContactElectronicAddressPropertySet

email = self.MapiContactElectronicAddress()

email.setAddressType(\"SMTP\")

email.setDisplayName(\"Melissa MacBeth (mellissa@contoso.com)\")

email.setEmailAddress(\"melissa@contoso.com\")

elec_addr_prop_set = self.MapiContactElectronicAddressPropertySet()

elec_addr_prop_set.setEmail1(email)

contact.setElectronicAddresses(elec_addr_prop_set)

contactSaveFormat = self.ContactSaveFormat

contact.save(self.dataDir + \"OutlookContact.vcf\", contactSaveFormat.VCard)

print \"Created outlook contact successfully.\"

הורד קוד רץ

הורד את Creating and Saving Outlook Contacts (Aspose.Email) מאתרי הקוד החברתי המופיעים למטה: