java - How do I read a message with an attachment and save the attachment from the content string? -


i using java mail emails gmail attachments, attachment come string in content, how can convert file?

thanks

this got

content : begin 644 myfile.csv m(e-t871u<r(l(e-t87)t(bpb4w1a<g0@9&%t92(l(e-t87)t('1i;64b+")% m;f0b+")%;f0@9&%t92(l(d5n9"!t:6ue(bpb0v%l;&en9r!c=7-t;vue<b(l ................. end  object content = message.getcontent();             if (content instanceof string) {//here got attachment                 system.out.println(content);             } else if (content instanceof multipart) {                 multipart multipart = (multipart) content;                 procesmultipart(multipart);             } 

looks have single part message uuencoded content. if message formatted content-transfer-encoding header of "uuencode", javamail decode automatically you. looks not. can decode using:

inputstream = mimeutility.decode(message.getinputstream(), "uuencode"); 

then read input stream decoded data, e.g., copy file.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -