Class MailBinding


  • public class MailBinding
    extends Object
    A Strategy used to convert between a Camel Exchange and Message to and from a Mail MimeMessage
    • Constructor Detail

      • MailBinding

        public MailBinding()
      • MailBinding

        @Deprecated
        public MailBinding​(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy,
                           ContentTypeResolver contentTypeResolver,
                           boolean decodeFilename)
        Deprecated.
      • MailBinding

        public MailBinding​(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy,
                           ContentTypeResolver contentTypeResolver,
                           boolean decodeFilename,
                           boolean mapMailMessage)
    • Method Detail

      • populateMailMessage

        public void populateMailMessage​(MailEndpoint endpoint,
                                        javax.mail.internet.MimeMessage mimeMessage,
                                        org.apache.camel.Exchange exchange)
                                 throws javax.mail.MessagingException,
                                        IOException
        Throws:
        javax.mail.MessagingException
        IOException
      • determineContentType

        protected String determineContentType​(MailConfiguration configuration,
                                              org.apache.camel.Exchange exchange)
      • determineCharSet

        protected static String determineCharSet​(MailConfiguration configuration,
                                                 org.apache.camel.Exchange exchange)
      • populateContentOnMimeMessage

        protected String populateContentOnMimeMessage​(javax.mail.internet.MimeMessage part,
                                                      MailConfiguration configuration,
                                                      org.apache.camel.Exchange exchange)
                                               throws javax.mail.MessagingException,
                                                      IOException
        Throws:
        javax.mail.MessagingException
        IOException
      • populateContentOnBodyPart

        protected String populateContentOnBodyPart​(javax.mail.BodyPart part,
                                                   MailConfiguration configuration,
                                                   org.apache.camel.Exchange exchange)
                                            throws javax.mail.MessagingException,
                                                   IOException
        Throws:
        javax.mail.MessagingException
        IOException
      • extractBodyFromMail

        public Object extractBodyFromMail​(org.apache.camel.Exchange exchange,
                                          MailMessage mailMessage)
        Extracts the body from the Mail message
      • extractAttachmentsFromMail

        public void extractAttachmentsFromMail​(javax.mail.Message message,
                                               Map<String,​org.apache.camel.attachment.Attachment> map)
                                        throws javax.mail.MessagingException,
                                               IOException
        Parses the attachments of the given mail message and adds them to the map
        Parameters:
        message - the mail message with attachments
        map - the map to add found attachments (attachmentFilename is the key)
        Throws:
        javax.mail.MessagingException
        IOException
      • extractAttachmentsFromMultipart

        protected void extractAttachmentsFromMultipart​(javax.mail.Multipart mp,
                                                       Map<String,​org.apache.camel.attachment.Attachment> map)
                                                throws javax.mail.MessagingException,
                                                       IOException
        Throws:
        javax.mail.MessagingException
        IOException
      • appendHeadersFromCamelMessage

        protected void appendHeadersFromCamelMessage​(javax.mail.internet.MimeMessage mimeMessage,
                                                     MailConfiguration configuration,
                                                     org.apache.camel.Exchange exchange)
                                              throws javax.mail.MessagingException,
                                                     IOException
        Appends the Mail headers from the Camel MailMessage
        Throws:
        javax.mail.MessagingException
        IOException
      • setRecipientFromEndpointConfiguration

        protected void setRecipientFromEndpointConfiguration​(javax.mail.internet.MimeMessage mimeMessage,
                                                             MailEndpoint endpoint,
                                                             org.apache.camel.Exchange exchange)
                                                      throws javax.mail.MessagingException,
                                                             IOException
        Appends the Mail headers from the endpoint configuration.
        Throws:
        javax.mail.MessagingException
        IOException
      • appendAttachmentsFromCamel

        protected void appendAttachmentsFromCamel​(javax.mail.internet.MimeMessage mimeMessage,
                                                  MailConfiguration configuration,
                                                  org.apache.camel.Exchange exchange)
                                           throws javax.mail.MessagingException,
                                                  IOException
        Appends the Mail attachments from the Camel MailMessage
        Throws:
        javax.mail.MessagingException
        IOException
      • addAttachmentsToMultipart

        protected void addAttachmentsToMultipart​(javax.mail.internet.MimeMultipart multipart,
                                                 String partDisposition,
                                                 AttachmentsContentTransferEncodingResolver encodingResolver,
                                                 org.apache.camel.Exchange exchange)
                                          throws javax.mail.MessagingException
        Throws:
        javax.mail.MessagingException
      • resolveContentTransferEncoding

        protected void resolveContentTransferEncoding​(AttachmentsContentTransferEncodingResolver resolver,
                                                      int i,
                                                      javax.mail.BodyPart messageBodyPart)
                                               throws javax.mail.MessagingException
        Throws:
        javax.mail.MessagingException
      • createMultipartAlternativeMessage

        protected void createMultipartAlternativeMessage​(javax.mail.internet.MimeMessage mimeMessage,
                                                         MailConfiguration configuration,
                                                         org.apache.camel.Exchange exchange)
                                                  throws javax.mail.MessagingException,
                                                         IOException
        Throws:
        javax.mail.MessagingException
        IOException
      • addBodyToMultipart

        protected void addBodyToMultipart​(MailConfiguration configuration,
                                          javax.mail.internet.MimeMultipart activeMultipart,
                                          org.apache.camel.Exchange exchange)
                                   throws javax.mail.MessagingException,
                                          IOException
        Throws:
        javax.mail.MessagingException
        IOException
      • shouldAddAttachment

        protected boolean shouldAddAttachment​(org.apache.camel.Exchange exchange,
                                              String attachmentFilename,
                                              DataHandler handler)
        Strategy to allow filtering of attachments which are added on the Mail message
      • extractHeadersFromMail

        protected Map<String,​Object> extractHeadersFromMail​(javax.mail.Message mailMessage,
                                                                  org.apache.camel.Exchange exchange)
                                                           throws javax.mail.MessagingException,
                                                                  IOException
        Throws:
        javax.mail.MessagingException
        IOException
      • hasAlternativeBody

        protected static boolean hasAlternativeBody​(MailConfiguration configuration,
                                                    org.apache.camel.Exchange exchange)
      • getAlternativeBody

        protected static String getAlternativeBody​(MailConfiguration configuration,
                                                   org.apache.camel.Exchange exchange)