Re: [Zope] sending attachments

2005-05-29 Thread Tino Wildenhain
Am Samstag, den 28.05.2005, 06:47 -0700 schrieb Varun Parange:
 hi,
  
 is it possible to send mails with attachments using Zope MailHost??
 if so,...how do u achieve it?
 

If you have a simple product like this:

EmailTools/__init__.py
--- contents -
from AccessControl import allow_module, allow_class, allow_type
from AccessControl import ModuleSecurityInfo, ClassSecurityInfo

from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.Header import Header
from MailCrypt import signmail
from email.Encoders import encode_base64

allow_class(BlockFormatter)
allow_class(MIMEBase)
allow_class(MIMEText)
allow_class(MIMEMultipart)
allow_class(Header)
allow_class(signmail)
allow_class(encode_base64)
---

You can send mails with attachment like this:

from Products.EmailTools import
MIMEText,MIMEBase,MIMEMultipart,Header,encode_base64

msg=MIMEMultipart()
inner=MIMEText(mailtext,_charset='iso-8859-1')
msg.attach(inner)
msg.add_header('Subject',str(Header(subject,iso-8859-1)))

# now the attachments:
for obj in context.attachments.objectValues('File'):
mt,st=obj.content_type.split(/)
p=MIMEBase(mt,st)
p.set_payload(str(obj))
p.add_header('content-disposition', 
 'attachment', 
 filename=obj.getId())
encode_base64(p)
msg.attach(p)

# now you are ready to send the mail like this:

context.YourMailHost.send(msg.as_string(),
  mfrom=Foobar [EMAIL PROTECTED],
  mto=[Someone [EMAIL PROTECTED]])


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] sending attachments

2005-05-28 Thread Varun Parange
hi,

is it possible to send mails with attachments using Zope MailHost??
if so,...how do u achieve it?__Do You Yahoo!?Tired of spam?  Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Sending attachments

2000-09-18 Thread Enric Cervera

Hi,

I've written a form whose contents are emailed with dtml-sendmail.
It works great, but I want to include a field in the form to select a
file
which should be included as an attachment in the email.

I've used dtml-mime and dtml-boundary as explained in the
manual but it does not work. The resulting email has the *name of the
file*
as the attachment instead of the file itself!

Anyone can help?

Thanks

Enric



___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )