Convert an email into its raw format using java

前端 未结 1 1399
攒了一身酷
攒了一身酷 2021-01-05 23:49

I tried until now to create an object of type MimeMessage using JavaMail api, and after that to obtain its raw representation, but with no success. The only thi

相关标签:
1条回答
  • 2021-01-06 00:09

    What you are looking for is MimeMessag#writeTo which outputs the message as an RFC 822 format stream.

    An example of using writeTo to convert a MimeMessage to a String.

    MimeMessage mimeMessage;
    
    // mimeMessage get assigned
    
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    mimeMessage.writeTo(output);
    String rawEmail = output.toString();
    
    0 讨论(0)
提交回复
热议问题