----------------------------------------------------------------------------
This is an example of a method to handle the mail messages as they arrive.
This particular example will create the folder structure year/month/day
(If it doesn't already exist) and place the email in the day folder with
all its file attachments.

To get this method to function you will need to create an external method
with the following properties.
	id: parseRfc822Date
	title: Parse rfc822 Date
	function name: parseRfc822Date
	python module file: ZMailInExtensions

----------------------------------------------------------------------------

<dtml-var standard_html_header>
<h2><dtml-var title_or_id> <dtml-var document_title></h2>

<dtml-in "theMail.keys()">
  <dtml-let Quay=sequence-item>
<B><dtml-var Quay>:</B> <dtml-var "theMail[Quay]"><BR>
  </dtml-let>
</dtml-in>

<dtml-let myDate="parseRfc822Date(theMail['date'])">
 <dtml-if expr="_.str(myDate[0]) not in PARENTS[1].objectIds()">
  <dtml-call "PARENTS[1].manage_addFolder(_.str(myDate[0]))">
 </dtml-if>

 <dtml-if expr="_.str(myDate[1]) not in PARENTS[1][_.str(myDate[0])].objectIds()">
  <dtml-call "PARENTS[1][_.str(myDate[0])].manage_addFolder(_.str(myDate[1]))">
 </dtml-if>

 <dtml-if expr="_.str(myDate[2]) not in PARENTS[1][_.str(myDate[0])][_.str(myDate[1])].objectIds()">
  <dtml-call "PARENTS[1][_.str(myDate[0])][_.str(myDate[1])].manage_addFolder(_.str(myDate[2]))">
 </dtml-if>

 <dtml-with "PARENTS[1][_.str(myDate[0])][_.str(myDate[1])][_.str(myDate[2])].manage_addProduct['ZMailMessage']">
  <dtml-call "manage_addZMailMessage(theMail['id'], theMail['title'], theMail['subject'], theMail['date'], theMail['to'], theMail['sender'], theMail['replyto'], theMail['body'], theMail['headers'])">
 </dtml-with>

 <dtml-with "PARENTS[1][_.str(myDate[0])][_.str(myDate[1])][_.str(myDate[2])][theMail['id']]">
  <dtml-in "theMail['attachments'].keys()">
   <dtml-let Quay=sequence-item>
    <dtml-call "manage_addFile(Quay,theMail['attachments'][Quay],Quay)">
   </dtml-let>
  </dtml-in>
 </dtml-with>
</dtml-let>

<dtml-var standard_html_footer>