Criando um Contato do Outlook no Aspose.Email
Contents
[
Hide
]
Esta dica de migração mostra como criar um contato do Microsoft Outlook usando a Automação do Microsoft Office e o Aspose.Email. O exemplo de código mostra como definir diferentes informações de um Contato, como informações Pessoais, Profissionais e Comerciais. Criar um contato do Outlook consiste nas seguintes etapas:
- Criar um objeto Contato.
- Preencher ou definir as várias propriedades do objeto.
- Salvar o objeto.
VSTO
//Create a new MapiContact Object
MapiContact mapiContact = new MapiContact();
//Set different properties of this Contact object
mapiContact.NameInfo = new MapiContactNamePropertySet("Mellissa", "", "MacBeth");
mapiContact.ProfessionalInfo.Title = "Account Representative";
mapiContact.ProfessionalInfo.CompanyName = "Contoso Ltd.";
mapiContact.ProfessionalInfo.OfficeLocation = "36/2529";
mapiContact.Telephones.BusinessTelephoneNumber = "4255551212 x432";
mapiContact.PhysicalAddresses.WorkAddress.Street = "1 Microsoft Way";
mapiContact.PhysicalAddresses.WorkAddress.City = "Redmond";
mapiContact.PhysicalAddresses.WorkAddress.StateOrProvince = "WA";
mapiContact.PhysicalAddresses.WorkAddress.PostalCode = "98052";
mapiContact.PhysicalAddresses.WorkAddress.Country = "United States of America";
mapiContact.ElectronicAddresses.Email1.EmailAddress = "milissa@contoso.com";
mapiContact.ElectronicAddresses.Email1.AddressType = "SMTP";
mapiContact.ElectronicAddresses.Email1.DisplayName = "Melissa MacBeth (mellissa@contoso.com)";
//Save the Contact object to disc
mapiContact.Save("Contact.vcf", ContactSaveFormat.VCard);
Aspose.Email
//Create a new MapiContact Object
MapiContact mapiContact = new MapiContact();
//Set different properties of this Contact object
mapiContact.NameInfo = new MapiContactNamePropertySet("Mellissa", "", "MacBeth");
mapiContact.ProfessionalInfo.Title = "Account Representative";
mapiContact.ProfessionalInfo.CompanyName = "Contoso Ltd.";
mapiContact.ProfessionalInfo.OfficeLocation = "36/2529";
mapiContact.Telephones.BusinessTelephoneNumber = "4255551212 x432";
mapiContact.PhysicalAddresses.WorkAddress.Street = "1 Microsoft Way";
mapiContact.PhysicalAddresses.WorkAddress.City = "Redmond";
mapiContact.PhysicalAddresses.WorkAddress.StateOrProvince = "WA";
mapiContact.PhysicalAddresses.WorkAddress.PostalCode = "98052";
mapiContact.PhysicalAddresses.WorkAddress.Country = "United States of America";
mapiContact.ElectronicAddresses.Email1.EmailAddress = "milissa@contoso.com";
mapiContact.ElectronicAddresses.Email1.AddressType = "SMTP";
mapiContact.ElectronicAddresses.Email1.DisplayName = "Melissa MacBeth (mellissa@contoso.com)";
//Save the Contact object to disc
mapiContact.Save("Contact.vcf", ContactSaveFormat.VCard);