Retrieving task attachment

I have an application that is downloading email and attachments.  One email has an attachment of content-type "task" ItemReference=1.  So I retrieve this by using getItemRequest instead of getAttachmentRequest.  The result of this is another .xml file.  This has various task properties such as due date, start date, which is good.  However there is also "hasAttachment=1" and a size of 1480757.  I was expecting that this .xml file would have further attachment data giving me the id of the task's attachment so I could download it, but nothing is there.  Is there a way that I can retrieve the attachment that seems to be part of this task?

Labels (2)
1 Reply
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: Retrieving task attachment

Sorry, I'm away from the office for a few days. I'm not sure how much information I can put in a reply. You have to recursively go through the emails. getting the embedded item by using getItemRequest, then reading the attachment data by streaming the attachment data or using getAttachAttachmentRequest (if the attachment data is small).

I did a quick hack. I created a simple message "one", with one attachment "config.txt". I embedded it in a second message "two". I create a simple java program to extract the data from the message:

private void testEmbeddedItem()
Mail item = (Mail) tvItems.getSelectionModel().getSelectedItem();
GetItemRequest request = new GetItemRequest();
GetItemResponse response;
request.setView("default message attachments");
response = port.getItemRequest(request);

if (response.getStatus().getCode() != 0 ||
response.getItem() == null)
item = (Mail)response.getItem();
if (!item.isHasAttachment())
AttachmentItemInfo info = item.getAttachments().getAttachment().get(0);

GetItemRequest emdItemReq = new GetItemRequest();
GetItemResponse emdItemResp;
emdItemReq.setView(("default message attachments"));
emdItemResp = port.getItemRequest(emdItemReq);

GetAttachmentRequest getRequest = new GetAttachmentRequest();
GetAttachmentResponse getResponse;
item = (Mail)emdItemResp.getItem();
if (!item.isHasAttachment())

info = item.getAttachments().getAttachment().get(0);
getResponse = port.getAttachmentRequestMessage(getRequest);

Please note, this is not the recommended way to do things. I could also provide a truncated soap trace of the output of the execution. Let me know if you still have questions of problems.


The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.