Question

I am working on a mail client using JavaMail which is working fine. Now I want to be able to handle read receipts for incoming messages. If an incoming message header contains "Disposition-Notification-To" I want to handle it and send back read receipt just as thunderbird and other mail clients handle it. I've googled a lot and go through the JavaMail API but am only seeing sending messages with read receipt enable and not handling incoming messages requiring read receipts. Any help appreciated.

Était-ce utile?

La solution

Here's the solution for those who may have the same problem. I know the above answer reiterated going back to the API but did not provide a solution or an example and thus cannot accept it as answer to my question. Am doing this from Jruby but it should be easy to convert it to normal Java:

 m = javax.mail.internet.MimeMessage.new(your_SMTP_obtained_session);
 m.setFrom(javax.mail.internet.InternetAddress.new(from_who));
 m.setSubject("Message Receipt (displayed) - #{original_message_subject}");
 m.addRecipient(javax.mail.internet.MimeMessage::RecipientType::TO, 
    javax.mail.internet.InternetAddress.new(destination_email_address));
 multireport = com.sun.mail.dsn.MultipartReport.new("Your text message to the" +
    "recipient i.e report content",com.sun.mail.dsn.DispositionNotification.new);
 m.setContent(multireport);

You now have a complete MimeMessage ready to be sent.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top