Forwarding Messages
¸Þ½ÃÁö¸¦ Æ÷¿öµù½ÃÅ°´Â °ÍÀº Á¶±Ý¸¸ ´õ ½Å°æ¾²¸é µÉ°ÍÀÌ´Ù.
È£ÃâÀ» À§ÇØ ¾î¶² ¸Þ¼Òµåµµ Á¸ÀçÇÏÁö ¾ÊÀ¸¸ç, ¸Þ½ÃÁö¸¦ ¸¸µå´Â °ÍÀº
´Ü¼øÈ÷ partµéÀº Á¶ÀÛÇÔÀ¸·Î¼ ¸¸µé¾î³¾¼ö ÀÖÀ»°ÍÀÌ´Ù.
¸ÞÀÏ ¸Þ½ÃÁö¸¦ multiple parts(¸ÞÀÏÀº PartÀÎÅÍÆäÀ̽ººÎÅÍ ½ÃÀÛÇÑ´Ù°í ¸»Çß¾ú´Ù.) ¸¸µêÀ¸·Î¼
°¡´ÉÇѵ¥, °¢°¢ÀÇ part´Â BodyPart, Áï Á¶±Ý´õ ±¸Ã¼ÀûÀ¸·Î ¸»Çϸé MIME message¸¦
Á¶ÀÛÇÒ ¶§ÀÇ MimeBodyParºÎºÐÀ̶ó°í ÇÒ¼ö ÀÖ´Ù.
¼·Î ´Ù¸¥ part¸¦ À§ÇØ ÄÁÅ×À̳ʰ¡ Multipart, MimeMultipart¸¦ È£ÃâÇÔÀ¸·Î½á
¸Þ½ÃÁö°¡ ±¸¼ºµÇ¾î Áú¼ö ÀÖ´Ù.
¸Þ½ÃÁö¸¦ Æ÷¿öµù½ÃÅ°±â À§Çؼ´Â ¸Þ½ÃÁöÀÇ ÅؽºÆ®¿¡ ÇϳªÀÇ part¸¦ »ý¼ºÇÑÈÄ ,
µÎ¹ø° part¸¦ »ý¼ºÇÏ°í, µÎ part¸¦ Á¶ÇÕÇϱâ À§Çؼ °ªµéÀ» multipart¾ÈÀ¸·Î Áý¾î³ÖÀ¸¸é µÈ´Ù.
±×·± ÈÄ¿¡´Â ¸Þ½ÃÁö¸¦ º¸³¾ °÷ÀÇ Á¤È®ÇÑ ÁÖ¼Ò¸¦ ÀÔ·ÂÇÑ ÈÄ º¸³»±â¸¸ ÇÏ¸é µÈ´Ù.
// Æ÷¿öµùÇÒ ¸Þ½ÃÁö¸¦ »ý¼ºÇÑ´Ù.
Message forward = new MimeMessage(session);
// Çì´õ¿¡ °ªÀ» ÀÔ·ÂÇÑ´Ù.(¼öÃëÀÎ Á¤º¸¹× º¸³½ÀÌ Á¤º¸µîµî)
forward.setSubject("Fwd: " + message.getSubject());
forward.setFrom(new InternetAddress(from));
forward.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// »õ·Î¿î MessagePart¸¦ »ý¼ºÇÑ´Ù.
//»ç½Ç ÀϹÝÀûÀÎ ¸Þ½ÃÁö¸¦ º¸³¾¶§´Â Message msg = new MimiMessage()¸¦ »ç¿ëÇß¾ú´Ù.
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(
"Here you go with the original message:\n\n");
// partµéÀ» Á¶ÇÕÇϱâ À§ÇØ MultiPart¸¦ »ý¼ºÇÑ´Ù
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// Æ÷¿öµùµÇ´Â ³»¿ëÀ» À§ÇØ part¸¦ »ý¼ºÇÏ°í, °ªÀ» ä¿î´Ù.
messageBodyPart = new MimeBodyPart();
// folder¿¡¼ ¾ò¾î¿Â °ª(message)
messageBodyPart.setDataHandler(message.getDataHandler());
// multi part¿¡ Part¸¦ Ãß°¡ÇÑ´Ù.
multipart.addBodyPart(messageBodyPart);
// ¸Þ½ÃÁö¸¦ multi-part¿¡ °áÇÕ½ÃŲ´Ù.
forward.setContent(multipart);
// ¸Þ½ÃÁö¸¦ º¸³½´Ù.
Transport.send(forward);
|
¿ä¹øÆí¿¡¼´Â °£·«ÇÏ°Ô ¸Þ½ÃÁö¸¦ Æ÷¿öµù½ÃÅ°´Â ¹æ¹ý¿¡ ´ëÇÏ¿© ¾Ë¾Æº¸¾Ò°í,
´ÙÀ½Æí¿¡¼´Â ÆÄÀÏ÷ºÎÇÏ´Â ¼Ò½ºÄڵ带 ÀÌ¿ëÇÏ¿© ÆÄÀÏÀ» Àü¼ÛÇÏ¿© º¸ÀÚ.
|