-2

I want a delivery receipt after sending email through java mail service and also want to save this receipt to CSV file in text format, send me a running code.

skaffman
  • 398,947
  • 96
  • 818
  • 769
perl
  • 1
  • 1
  • 1
  • 4
    "send me a running code"... Note, this website isn't a code factory, where you submit your requirements and get a ready-made program back. Please show some effort yourself - what did you try, where do you get stuck? – Jesper Oct 01 '09 at 09:54
  • I agree with Jesper. But it is also possible that the OP's first language is not English, and the meaning conveyed to those who understand English well was unintentional. But then again, a "Please" is not hard to learn or type :) – talonx Oct 29 '09 at 08:32

1 Answers1

4

In order to request a delivery receipt you upon delivery you have to use com.sun.mail.smtp.SMTPMessage. Given your message in msg:

SMTPMessage smtpMsg = new SMTPMessage(msg);
smtpMsg.setReturnOption(SMTPMessage.RETURN_HDRS);
smtpMsg.setNotifyOptions(
  SMTPMessage.NOTIFY_DELAY|SMTPMessage.NOTIFY_FAILURE|SMTPMessage.NOTIFY_SUCCESS);

Now you will receive a delivery-status mail upon delivery. This mail is of mime-type multipart/report, sub-tpye delivery-status. It consists of text/plain part with a human readable message, a message/delivery-status part with a machine readable (and standardized) message as wells as an (optional) part with the original message attached. Think about what exactly you want to save to file.

See also RFC 1891 - 1894 for reference.

erik
  • 253
  • 2
  • 11