Handle contact information on Exchange Server per Java

Hello,

we are in the process of evaluating Aspose.EMail for Java.

I have the following question:
Is it possible to create, update and delete contacts on Exchange Server per Java.
Furthermore i would like to know, if setting a birthday date within a contact (per EWS) will result in an annual appointment in the calendar?
Thanks a lot.

Best regards,
Matthias Schlosser

Hi Matthias,

Thank you for contacting Aspose support team.

Aspose.Email for Java can be used to process contacts on exchange. You may please use following sample code to access the contacts.

public static void GetContacts()

{

// Create instance of IEWSClient class by giving credentials
IEWSClient client = EWSClient.getEWSClient(“https://outlook.office365.com/ews/exchange.asmx” , “testUser” , “pwd” , “domain” );

// List all the contacts

//MapiContact[] contacts = client.listContacts(client.getMailboxInfo().getContactsUri());
MapiContact[] contacts = client.listContacts(client.getMailboxInfo().getContactsUri());

// Loop through all contacts
for (MapiContact contact : contacts)

{

// Display name and email address
System.out .print(“Execution completed successfully” );

System.out .print("Name: " + contact.getNameInfo().getDisplayName() +

", Email Address: " + contact.getElectronicAddresses().getEmail1());

}

}

public static void ResolveContactUsingContactName()

{

// Create instance of IEWSClient class by giving credentials
IEWSClient client = EWSClient.getEWSClient(“https://outlook.office365.com/ews/exchange.asmx” , “testUser” , “pwd” , “domain” );

// List all the contacts
Contact[] contacts = client.resolveContacts(“Changed Name” , ExchangeListContactsOptions.FetchAttachmentAndFullPhotoInformation );

// Loop through all contacts
for (Contact contact : contacts)

{

// Display name and email address
System.out .print(“Name: " + contact.getDisplayName() +”, Email Address: " + contact.getEmailAddresses());

}

}

public static void CreateContact()

{

// Create instance of EWSClient class by giving credentials
IEWSClient client = EWSClient.getEWSClient(“https://outlook.office365.com/ews/exchange.asmx” , “testUser” , “pwd” , “domain” );

//Initialize MapiContact object and populate contact information
MapiContact contact = new MapiContact();

contact.setElectronicAddresses(null );

contact.setTelephones(null );

contact.setNameInfo(new MapiContactNamePropertySet(“John” , “” , “Doe” ));

//Create the contact on the Exchange server
client.createContact(contact);

}

public static void DeleteContact()

{

// Create instance of EWSClient class by giving credentials
IEWSClient client = EWSClient.getEWSClient(“https://outlook.office365.com/ews/exchange.asmx” , “testUser” , “pwd” , “domain” );

String strContactToDelete = “John Teddy” ;

Contact[] contacts = client.getContacts(client.getMailboxInfo().getContactsUri());

for (Contact contact : contacts)

{

if (contact.getDisplayName().equals(strContactToDelete))

client.deleteContact(contact);

}

client.dispose();

}

public static void UpdateContact()

{

IEWSClient client = EWSClient.getEWSClient(“https://outlook.office365.com/ews/exchange.asmx” , “testUser” , “pwd” , “domain” );

// List all the contacts
Contact[] contacts = client.getContacts(client.getMailboxInfo().getContactsUri());

// Loop through all contacts
Contact contact = contacts[0];

System.out .print("Name: " + contact.getDisplayName());

contact.setDisplayName(“David Ch” );

client.updateContact(contact);

}

I am afraid that there is no such feature available which can be used to add automatically annual appointment against the birthday set in the contact. Please feel free to write us back if you have any other query related to Aspose.Email.