This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Description
Folks,
The following code raises an internal server exception. The item object in the 2nd argument of my method actually cast from a valid Contact object. The client is verified to be valid, the mail Id came from a new message I created and did not send yet. The message sits in the user's draft mail message folder.
I get the following internal server (501) error:
"Object reference not set to an instance of an object”
/**
* Gets a message out of the user's draft folder by id and adds a text file attachment
*
* @param mailId The id of the draft email that will get the attachment
* @param itemToAttach The mail message to attach
* @return Boolean. The result of the operation. True if success
* @version 1.0
*/
public Boolean addItemAttachment(
String mailId
, Item itemToAttach) throws ExecutionException, InterruptedException {
ItemAttachment itemAttachment = new ItemAttachment();
itemAttachment.setName(itemToAttach.getClass().getName());
itemAttachment.setItem(itemToAttach);
itemAttachment.setContentType(itemToAttach.getClass().getName());
itemAttachment.setIsInline(false);
itemAttachment.setId(itemToAttach.getId());
mMailClient
.getMe()
.getMessages()
.getById(mailId)
.getAttachments()
.add(itemAttachment)
.get();
return true;
}