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

Cannot attach Contact as ItemAttachment to an email #75

@JohnMAustin78

Description

@JohnMAustin78

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions