Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-13-2010, 07:49 AM
New Member
 
Posts: 4
Unhappy [SOLVED] How to retrieve/save an attachment file in a mail with SaveDocumentRequest ?

Hello all

I need to download an attachment file from a mail in SOAP with Java classes in com.zimbra.cs.zclient but I am having trouble.

For this I've done these following steps :
1) I get the corresponding mail with ZConversation and ZMessage
2) I retrieve the MimePart of the mail with ZMimePart
3) In the response of the GetMsgRequest I only have for information (concerning the attachment file(s)) : their name - size - type and the idPart of the message

Code:
Response : <mp s="773" filename="monFichier.xml" part="2" ct="application/xml" cd="attachment"/><mp s="86047" filename="monFichier2.jsp" part="3" ct="application/octet-stream" cd="attachment"/></mp>
4) I have guessed that the solution is to call the SaveDocumentRequest which is detailed in ZimbraServer/doc/soap-wiki.txt (or in http://www.lahtermaher.org/pub/zimbr.../soap-wiki.txt) like this :

Code:
<SaveDocumentRequest>
  <doc [id="{item-id}" ver="{last-known-version}"] [name="{file-name}"] [ct="{content-type}"] [l="{folder-id}"]>
    [<upload id="{upload-id}"/>]
    [<m id="{msg-id}" part="{part-id}"/>]
  </doc>
</SaveDocumentRequest>
But when I do the request an error occurs :

Here is the request I made (with the information I can fill in :
Code:
<SaveDocumentRequest xmlns="urn:zimbraMail"><doc name="monFichier2.jsp" l="5" ct="application/octet-stream"><m id="354" part="3"/></doc></SaveDocumentRequest>
Here is the error message (in zimbra/log/mailbox.log) :
Code:
com.zimbra.common.soap.SoapFaultException: system failure: cannot create ParsedDocument
Code:service.FAILURE
	at com.zimbra.common.service.ServiceException.FAILURE(ServiceException.java:247)
Is anybody know how to resolve this ?

Thank you in advance for your help.

Reply With Quote
  #2 (permalink)  
Old 01-14-2010, 04:03 AM
New Member
 
Posts: 4
Default

Eventually I found the answer.

With the GET_MSG_REQUEST I get the url REST of the concerned file. For this I have set the MailConstants.A_PART and the MailConstants.A_RAW attributes.
Then I get the content of the file (an inputstream) with this line :

Code:
ZMailbox.getRESTResource(urlREST);
I hope this post may interest some of you

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.