Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Send a message with zope (See related posts)

// description of your code here


      # get a correct mail

      searching_obj = context
      interesatuen_epostak = []

      while interesatuen_epostak == []:
            if searching_obj.interesatuen_epostak != []:
               for m in searching_obj.interesatuen_epostak:
                   if '@' in m:
                      interesatuen_epostak.append(m)
            searching_obj = searching_obj.aq_parent


      # send a mail

      try:
        mailhost=getattr(context, context.superValues('Mail Host')[0].id)
      except:
        raise AttributeError, "cant find a Mail Host object"

      for i in interesatuen_epostak: 
       mMsg = "To: " + i + "\n"
       mMsg = mMsg + "From: intranet@zenbaki.es\n"
       mMsg = mMsg + "Mime-Version: 1.0\n"
       mMsg = mMsg + "Content-Type: text/html; charset=ISO-8859-1\n\n"

       mMsg = mMsg + "<html><head></head><body bgcolor='#dddddd'>"
       mMsg = mMsg + "<h1>Aldaketak:</h1>"
       mMsg = mMsg + "<p>"+user.getUserName()

       if user.getUserName()[-1] in ['a','e','i','o','u']:
          mMsg = mMsg + "k,"
       else:
          mMsg = mMsg + "ek,"

       mMsg = mMsg + " '<a href='"+obj.absolute_url()+"'>"+obj.title+"</a>' HTML fitxategia gehitu zuen "
       mMsg = mMsg + "'<a href='"+container_folder.absolute_url()+"'>"+container_folder.id+"</a>' izendako karpetan.</p>"
       mMsg = mMsg + "</body></html>"

       mSubj = "[intranet] '"+obj.title+"' HTML fitxategia gehituta izan zen"
       mailhost.send(mMsg, subject=mSubj, encode='base64')

Comments on this post

nando.quintana posts on Feb 20, 2007 at 05:28
This is the way we use to do it with zope 2

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts