Re: [Zope] sending attachments

2005-05-31 Thread Vital Lobachevsky

Varun Parange wrote:

hi,
 
is it possible to send mails with attachments using Zope MailHost??

if so,...how do u achieve it?


I use DTML method to send .csv-file as attachment:



To: 
From: 
Subject: 




encode="base64" filename="addresses.csv">expr="msgFile">




I hope it helps.


___
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 )


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 )


Re: [Zope] sending attachments

2005-05-28 Thread Andreas Jung



--On 28. Mai 2005 06:47:14 -0700 Varun Parange <[EMAIL PROTECTED]> 
wrote:



hi,

is it possible to send mails with attachments using Zope MailHost??



MailHost is for sending out emails but  not for composing emails in any way.
Look at  or Python's 'email' module (-> Python Library Ref).

-aj



pgpkJkj5lHjgx.pgp
Description: PGP signature
___
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 )