Class MailBinding

java.lang.Object
org.apache.camel.component.mail.MailBinding

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

    • 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)
    • MailBinding

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

      public MailBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy, ContentTypeResolver contentTypeResolver, boolean decodeFilename, boolean mapMailMessage, boolean failOnDuplicateAttachment, String generateMissingAttachmentNames, String handleDuplicateAttachmentNames)
  • Method Details

    • isFailOnDuplicateAttachment

      public boolean isFailOnDuplicateAttachment()
    • setFailOnDuplicateAttachment

      public void setFailOnDuplicateAttachment(boolean failOnDuplicateAttachment)
    • populateMailMessage

      public void populateMailMessage(MailEndpoint endpoint, jakarta.mail.internet.MimeMessage mimeMessage, org.apache.camel.Exchange exchange) throws jakarta.mail.MessagingException, IOException
      Throws:
      jakarta.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(jakarta.mail.internet.MimeMessage part, MailConfiguration configuration, org.apache.camel.Exchange exchange) throws jakarta.mail.MessagingException, IOException
      Throws:
      jakarta.mail.MessagingException
      IOException
    • populateContentOnBodyPart

      protected String populateContentOnBodyPart(jakarta.mail.BodyPart part, MailConfiguration configuration, org.apache.camel.Exchange exchange) throws jakarta.mail.MessagingException, IOException
      Throws:
      jakarta.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(jakarta.mail.Message message, Map<String,org.apache.camel.attachment.Attachment> map) throws jakarta.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:
      jakarta.mail.MessagingException
      IOException
    • extractAttachmentsFromMultipart

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

      protected void handleDuplicateFileAttachment(jakarta.mail.Multipart mp, String duplicateFileName) throws jakarta.mail.MessagingException
      Strategy for handling extracting mail message that has duplicate file attachments
      Parameters:
      mp - the multipart entity
      duplicateFileName - the duplicated file name
      Throws:
      jakarta.mail.MessagingException - is thrown, failing with an error
    • appendHeadersFromCamelMessage

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

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

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

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

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

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

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

      protected boolean shouldAddAttachment()
      Strategy to allow filtering of attachments which are added on the Mail message
    • extractHeadersFromMail

      protected Map<String,Object> extractHeadersFromMail(jakarta.mail.Message mailMessage, org.apache.camel.Exchange exchange) throws jakarta.mail.MessagingException, IOException
      Throws:
      jakarta.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)
    • getGenerateMissingAttachmentNames

      public String getGenerateMissingAttachmentNames()
    • setGenerateMissingAttachmentNames

      public void setGenerateMissingAttachmentNames(String generateMissingAttachmentNames)
    • getHandleDuplicateAttachmentNames

      public String getHandleDuplicateAttachmentNames()
    • setHandleDuplicateAttachmentNames

      public void setHandleDuplicateAttachmentNames(String handleDuplicateAttachmentNames)