[Zope] mimetools -- an example, I hope this helps

Clarence.Pate@bridge.bellsouth.com Clarence.Pate@bridge.bellsouth.com
Mon, 20 Mar 2000 07:52:14 -0600


I had to play around to get mime stuff to work right.  I needed to email
messages to about 1500 people.  Every person reaceived a couple of documents
that were the same, and each person received one document that was unique for
that individual.  I also through in a timer loop to provide a one minute delay
between each email message.  (Our mail server could not handle the load.)  I am
enclosing the code that worked for me.  Of course ymmv :)


pull_contacts : this is an sql method which pulls user information out of an
Access database.  Most of the variables listed come out of this database.

dtml-log : I used the logger product to create some logs so that I could see
that my mail messages went out.  I don't think this worked the way I wanted it
to work.

mime tag :  I added some custom code to the mime stuff because the mime stuff
does not add the mime version 1.0 header.  This may not cause problems for
everyone else, but it does cause problems for HP OpenMail and Lotus Notes.  I
do not know if anyone has fixed this in the standard zope code, but it was not
working when I did this mailout.

"_[QUESTION].data" :  this was what I had to do to pull in the unique object
for each individual.  (I imported all of my documents into the zodb.)

<!--#var standard_html_header-->
<!--#in pull_contacts-->
<dtml-log severity=INFO subsystem=ContactReports>
<dtml-logdetail>
<!--#var SSN-->;<!--#var LAST_NAME-->,<!--#var FIRST_NAME--> <!--#var
MIDDLE_INIT-->;<!--#var SENDMAIL-->
start timer: <!--#var ZopeTime-->;<!--#call sleeptime-->
stop timer: <!--#var ZopeTime-->;
</dtml-log>
<dtml-try>
<!--#sendmail
  mailfrom="dilbert@dilbert.com"
  smtphost="mail.dilbert.com"-->
Subject: !!!This is an email message!!!
To: <!--#var SENDMAIL-->
<!--#mime type=text/plain encode=7bit version=1-->
TO   : <!--#var LAST_NAME-->, <!--#var FIRST_NAME--> <!--#var MIDDLE_INIT-->
EMAIL: <!--#var EMAIL-->
FROM :  dilbert
EMAIL:  dilbert@dilbert.com

This is part of the message from dilbert

<!--#boundary type=application/msword
 disposition=attachment
 name="recert.doc"
 encode=base64--><!--#var "bscontact_recert_letter2.data"-->
<!--#boundary type=application/msword
 disposition=attachment
 name="steps.doc"
 encode=base64--><!--#var "bscontact_steps.data"-->
<!--#boundary type=application/msword
 disposition=attachment
 name="question.doc"
 encode=base64--><!--#var
 "_[QUESTION].data"-->
<!--#boundary type=application/msword
 disposition=attachment
 name="css_docs.doc"
 encode=base64--><!--#var
 "css_docs.data"--><!--#/mime-->
<!--#/sendmail-->
<p>
mailed;<!--#var SSN-->;<!--#var LAST_NAME-->;<!--#var FIRST_NAME-->;<!--#var
MIDDLE_INIT-->;<!--#var SENDMAIL-->;<!--#var ZopeTime-->;<!--#call
sleeptime--><!--#var ZopeTime-->;;
</p>
<dtml-except>
<p>
failed;<!--#var SSN-->;<!--#var LAST_NAME-->;<!--#var FIRST_NAME-->;<!--#var
MIDDLE_INIT-->;<!--#var SENDMAIL-->;<!--#var ZopeTime-->;<!--#call
sleeptime--><!--#var ZopeTime-->;<!--#var error_value-->;
</p>
</dtml-try>
<!--#else-->
  There was no data matching this <!--#var title_or_id--> query.
<!--#/in-->
<h2>Thanks for playing the game!</h2>
<!--#var standard_html_footer-->


Clarence T. Pate