Adapter event for the IMAP adapter

You can configure an IMAP mail monitor adapter to download or ignore attachments to the email message being monitored.

Working with email attachments

The sample event in the following figure shows a configuration to display attachments. The sample shows a value for a file that is downloaded, where the <create-subdirectory> element is set to true in the adapter configuration. If an attachment cannot be downloaded, the event includes a <fault-message> element in the <attachment> block, indicating the problem. Each attachment is evaluated independently. You can have a message with multiple attachments, some of which are downloaded successfully, while others produce an error or fault message.

To use the data from the monitor adapter event in the triggered process, you must create inputevent, a job input parameter on the Start activity of the process. The <data> element from the monitor adapter event populates this input.

The following table describes the <attachments> element for the IMAP mail adapter.

IMAP mail adapter event with <attachments> element

Element

Description

<email-message>

Contains the values for the email message

<from>

Contains the email address of the sender

<email-address>

Specifies the email address of the account to be monitored

<sent-date>

Specifies the date the email message is sent

<sent-epoch-milliseconds>

Specifies the date the email message is sent, in epoch time format

This value can be used to perform a date comparison in a rule.

<reply-to>

Specifies the addresses to which a reply to the email message is directed

<recipients>

Contains the email address of the recipients

<subject>

Specifies the subject line of the email message

<body>

Specifies the body of the email message

<attachments>

Contains the information about attachments to the email message

<attachment>

Contains the information about an attachment to the email message

<peer-name>

Specifies the name of the peer on which the attachment is downloaded

<download-directory>

Specifies the directory in which the attachment is downloaded

<name>

Specifies the file name of the attachment that is downloaded

The following figure shows a sample XML of the IMAP adapter event with an attachment that is downloaded successfully.

XML sample of the IMAP adapter event with an attachment downloaded successfully

<email-message>
  <from>
  <email-address>email</email-address>          
  </from>
  <sent-date>date</sent-date>
  <sent-epoch-milliseconds>date in epoch time</sent-epoch-milliseconds>
  <reply-to>
  <email-address>email</email-address>
  <email-address>email</email-address>
  </reply-to>
  <recipients>
  <email-address>email</email-address>
  <email-address>email</email-address>
  </recipients>
  <subject>subject text</subject>
  <body>
    <bodypart>This is attachment&#xD;</bodypart>
     <bodypart>This is the content of the message part of Content-Type text/plain or 
      text/html (which appears as an attachment with content disposition value inline and
        null description value) is added in bodypart instead of an attachment.#xD;
     </bodypart>
  </body>
  <attachments>
  <attachment>
    <peer-name>CDP</peer-name>
    <download-directory>/mail/downloads/user@company.com/Message1/1196967357
     </download-directory>
    <name>Test1.doc</name>
  </attachment>
  <attachment>
    <peer-name>CDP</peer-name>
    <download-directory>/mail/downloads/user@company.com/Message2/1196968330
    </download-directory>
    <name>Test2.doc</name>
  </attachment>
  </attachments>
</email-message>

Working with email recipient headers

For a nested (forwarded) message, the adapter event XML contains the details in the header. The header contains details of all recipients (such as To, Cc, and Bcc), from, subject, and sent date. These values are included in the corresponding elements, which are added as child elements of one of the <bodypart> element in the event XML as shown in the XML sample of the IMAP adapter event for a nested message.

The following table describes the adapter event elements for the IMAP mail adapter for a nested message with header details.

IMAP mail adapter event for a nested message with header details

Element

Description

<to>

Contains the names of all the email recipients in the To list of the nested message

<cc>

Contains the names of all the email recipients in the Cc list of the nested message

<bcc>

Contains the names of all the email recipients in the Bcc list of the nested message

<from>

Contains the email address of the sender of the nested email message

<subject>

Specifies the subject line of the nested email message

<date>

Contains the date when the nested email is sent

The following figure shows a sample XML of the IMAP adapter event for a nested message.

XML sample of the IMAP adapter event for a nested message

<email-message>
  <from>
    <email-address>abcd@xyz.com</email-address>
  </from>
  <sent-date>Thu Dec 30 14:45:40 GMT+05:30 2010</sent-date>
  <sent-epoch-milliseconds>1293700540000</sent-epoch-milliseconds>
  <reply-to>
    <email-address>abcd@xyz.com</email-address>
  </reply-to>
  <recipients>
    <email-address>qatesting102@yyy.com</email-address>
  </recipients>
  <subject>FW: This is test message with CC list nested message</subject>
  <body>
    <bodypart>Forwarding nested message.....&#xD; &#xD;
     --ABCD&#xD;
     &#xD;
      From: ABCD&#xD;
      Sent: Friday, December 24, 2010 3:17 PM&#xD;
      To: 'test@gmail.com'&#xD;
      Cc: 'somename@gmail.com'&#xD;
      Subject: This is test message with CC list nested message&#xD; &#xD;
      This is test&#xD;
      &#xD;
     --ABCD&#xD;
     </bodypart>
     <bodypart>
      <from>ABCD &lt;test@gmail.com&gt;</from>
      <to>"ABCD" &lt;abcd@xyz.com&gt;, "test@gmail.com"&#xD;
	           &lt;test@gmail.com&gt;</to>
      <cc>"somename@gmail.com" &lt;somename@gmail.com&gt;, Some Name&#xD;
           	&lt;name2@gmail.com&gt;</cc>
      <subject>Fwd: This is the nested message to test headers information</subject>
      <date>Fri, 24 Dec 2010 03:44:59 -0600</date>
    </bodypart>
    <bodypart>&#xD;
    &#xD;
---------- Forwarded message ----------&#xD;
    From: ABCD &lt;abc@gmail.com&lt;mailto:test@gmail.com&gt;&gt;&#xD;
    Date: Fri, Dec 24, 2010 at 2:38 PM&#xD;
    Subject: This is the nested test message to test headers information&#xD;
    To: test@gmail.com&lt;mailto:test@gmail.com&gt;,
     abcd@xyz.com&lt;mailto:abcd@xyz.com&gt;,
     somename@gmail.com&lt;mailto:somename@gmail.com&gt;, Some Name 
     &lt;name2@gmail.com&lt;mailto:name2@gmail.com&gt;&gt;, Some Name2
     &lt;test@yahoo.co.in&lt;mailto:test@yahoo.co.in&gt;&gt;&#xD;
    &#xD;
    &#xD;
    This is the nested test message to test headers&#xD;
    &#xD;
    </bodypart>
  </body>
</email-message>

The following table describes the adapter event elements for the IMAP mail adapter with an attachment that cannot be downloaded.

IMAP mail adapter event elements for an attachment that cannot be downloaded

Element

Description

<email-message>

Contains the elements for the email message

<from>

Specifies the email address of the sender

<sent-date>

Specifies the date the email message is sent

<sent-epoch-milliseconds>

Specifies the date the email message is sent, in epoch time format

This value can be used to perform a date comparison in a rule.

<reply-to>

Specifies the addresses to which a reply to the email message is directed

<recipients>

Specifies the email addresses of the recipients

<subject>

Specifies the subject line of the email message

<body>

Specifies the body of the email message

<attachments>

Contains information about the attachments to the email message

<attachment>

Contains the information about an attachment to the email message

<fault-message>

Specifies the reason why the attachment could not be downloaded successfully

<name>

Specifies the file name of the attachment that could not be downloaded

The following figure shows a sample XML of the adapter event for the IMAP adapter with an attachment that cannot be downloaded.

XML sample of the IMAP mail adapter event with an attachment that cannot be downloaded

<email-message>
  <from>
    <email-address>email</email-address> 
  </from>
  <sent-date>date</sent-date>
  <sent-epoch-milliseconds>date in epoch time</sent-epoch-milliseconds>
  <reply-to>
    <email-address>email</email-address>
    <email-address>email</email-address>
  </reply-to>
    <recipients>
    <email-address>email</email-address>
    <email-address>email</email-address>
  </recipients>
  <subject>subject text</subject>
  <body>body text</body>
  <attachments>
    <attachment>
      <fault-message> Attachment could not be downloaded  attachment name 
      violates filter set</fault-message>
      <name>Sample1.doc</name>
    </attachment>
    <attachment>
      <fault-message> Attachment could not be downloaded as it exceeds maximum attachment 
      size limit </fault-message>
      <name>Sample2.doc</name>
    </attachment>
  </attachments>
</email-message>

The following figure shows a sample XML of the IMAP adapter event when the <ignore-peer-name-in-attachment> element is set to true while configuring the adapter.

XML sample of the IMAP mail adapter event when ignore-peer-name-in-attachment> is set to true

<email-message>
  <from>
    <email-address>abc@gmail.com</email-address>
  </from>
  <sent-date>Fri Jun 11 19:02:11 GMT+05:30 2010</sent-date>
  <sent-epoch-milliseconds>1276263131000</sent-epoch-milliseconds>
  <reply-to>
    <email-address>abc@gmail.com</email-address>
  </reply-to>
  <recipients>
    <email-address>username@runbox.com</email-address>
  </recipients>
  <subject>IMAP</subject>
  <body>
    <bodypart>This is attachment&#xD;
    </bodypart>
 </body>
  <attachments>
    <attachment>
     <download-directory>C:\AO\CDP\tomcat\temp\username@runbox.com</download-directory>
     <name>test.txt</name>
    </attachment>`
  </attachments>
</email-message>

The following log sample shows an email trap received by the adapter when the adapter supports Internet protocol version 6 (IPv6):

 Click here to expand...

27 Feb 2012 11:36:39,827 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Message-ID: <1356889452.20120227113415@4BPV1BS-559.abcd.efg.com>
27 Feb 2012 11:36:39,827 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: MIME-Version: 1.0
27 Feb 2012 11:36:39,827 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Content-Type: text/plain; charset="iso-8859-1"
27 Feb 2012 11:36:39,827 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Content-Transfer-Encoding: quoted-printable
27 Feb 2012 11:36:39,827 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: X-Mailer: Ability Mail Server 2012 WebMail (by Code-Crafters)
27 Feb 2012 11:36:39,827 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Inside getText: part getDescription is :  null
27 Feb 2012 11:36:39,827 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Inside getText: part getLineCount is :  2
27 Feb 2012 11:36:39,827 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Inside getText: part getFileName is :  null
27 Feb 2012 11:36:39,827 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Inside getText: part Disposition is :  null
27 Feb 2012 11:36:39,829 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Content type is =text/plain; charset=iso-8859-1
27 Feb 2012 11:36:39,829 DEBUG BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Parsing body using Charset iso-8859-1
27 Feb 2012 11:36:39,829 DEBUG MailMonitorJobProcessor : pool-10-thread-1: IMAP_IPV6: captured the new Message from emailid@abcd.efg.com : <email-message>
  <from>
    <email-address>emailid@abcd.efg.com</email-address>
  </from>
  <sent-date>Mon Feb 27 11:34:15 IST 2012</sent-date>
  <sent-epoch-milliseconds>1330322655000</sent-epoch-milliseconds>
  <reply-to />
  <recipients>
    <email-address>emailid@abcd.efg.com</email-address>
  </recipients>
  <subject>danger  danger   danger   danger  danger  danger</subject>
  <body>
    <bodypart>danger  danger  danger  danger  danger

</bodypart>
  </body>
</email-message>
27 Feb 2012 11:36:39,829 INFO  BaseMailMonitorAdapter : pool-10-thread-1 IMAP_IPV6: Sending event to adapter manager : <email-message>
  <from>
    <email-address>emailid@abcd.efg.com</email-address>
  </from>
  <sent-date>Mon Feb 27 11:34:15 IST 2012</sent-date>
  <sent-epoch-milliseconds>1330322655000</sent-epoch-milliseconds>
  <reply-to />
  <recipients>
    <email-address>emailid@abcd.efg.com</email-address>
  </recipients>
  <subject>danger  danger   danger   danger  danger  danger</subject>
  <body>
    <bodypart>danger  danger  danger  danger  danger

</bodypart>
  </body>
</email-message>
27 Feb 2012 11:36:39,829 DEBUG MailMonitorJobProcessor : pool-10-thread-1: IMAP_IPV6: Event sent successfully for emailid@abcd.efg.com
27 Feb 2012 11:36:39,830 INFO  AdapterManager  : ADAPTER_MANAGER: IMAP_IPV6 sent event: Email received
27 Feb 2012 11:36:39,830 DEBUG AdapterProxy    : Attempting to locate a peer with a running Activity Processor instance to process a rules job...
27 Feb 2012 11:36:39,830 DEBUG AdapterProxy    : Located a running instance of the Activity Processor on peer "CDP1". Attempting to send a submit rules job request...
27 Feb 2012 11:36:39,831 DEBUG AdapterProxy    : Successfully submitted rules job to peer "CDP1".
27 Feb 2012 11:36:39,881 DEBUG BaseMailMonitorAdapter : pool-9-thread-1 IMAP_IPV6: Store connected for target [fe80::5097:4c5e:2289:76dd]
27 Feb 2012 11:36:39,888 DEBUG ImapMailMonitorThread : pool-9-thread-1: IMAP_IPV6: newMessageCount 3 for target emailid@abcd.efg.com
27 Feb 2012 11:36:39,888 DEBUG ImapMailMonitorThread : pool-9-thread-1: IMAP_IPV6: oldMessageCount 3 for target emailid@abcd.efg.com
27 Feb 2012 11:36:39,888 DEBUG ImapMailMonitorThread : pool-9-thread-1: IMAP_IPV6: no new messages on server 

Handling javax.mail.internet.AddressException

If the email sender does not specify the recipient email addresses in the recipient headers of the message as per the RFC standards, the adapter fails with the javax.mail.internet.AddressException where the API is unable to parse the recipients list and unable process the email event.

The adapter has now been enhanced to directly retrieve the recipients list from the recipient headers in a string format separated by a delimiter and add to the email event in the following format inside the<recipients> element.  

<recipients>
  <To><![CDATA[abc@aps-eml.com, allen@aps-eml.com]]></To>
  <Cc><![CDATA[xyz@aps-eml.com, xyz@aps-eml.com;myemail@gmail.com;]]></Cc>
</recipients>
Was this page helpful? Yes No Submitting... Thank you

Comments