Re: Mail (Supplement)
zoops4@yahoo.com wrote:
Hi,
I am trying to send e-mail with attachment using <dtml-sendmail>. I noticed you had the same problem earlier, therefore I hope you can give me some suggestions. This is the code that I am using
First try:
<dtml-mime type=text/plain encode=7bit>
<dtml-boundary type=application/octet-stream disposition=attachment encode=base64> <dtml-var "selected_image.read()">
</dtml-mime>
first error:
Error Type: AttributeError Error Value: 'string' object has no attribute 'read'
Second try:
<dtml-mime type=text/plain encode=7bit>
<dtml-boundary type=application/octet-stream disposition=attachment encode=base64> <dtml-var "restrictedTraverse(selected_image).read()">
</dtml-mime>
Second Error:
Error Type: AttributeError Error Value: read
Thank you in ahead of time.
Vid
Hi Vid (You mailed me personally, but I cc to the list with your permission ;-) This code is working for me with documents and files (but not with images stored in the ZODB); I tried it with binary, pdf and html content. <dtml-sendmail mailhost="MailHost"> From: <dtml-var sender> To: <dtml-var recipient> Date: <dtml-var ZopeTime fmt="rfc822"> Subject: Testmessage <dtml-mime type="text/plain" encode="7bit"> testmessage textbody <dtml-boundary type="application/octet-stream" disposition="attachment" encode="base64" filename="testfile"><dtml-var testfile></dtml-mime> </dtml-sendmail> Regards --- Flynt (Supplement) Hi Vid Here is the code, to send an image: <dtml-sendmail mailhost="MailHost"> From: <dtml-var sender> To: <dtml-var recipient> Date: <dtml-var ZopeTime fmt="rfc822"> Subject: Testmessage <dtml-mime type="text/plain" encode="7bit"> testmessage textbody <dtml-boundary type="application/octet-stream" disposition="attachment" encode="base64" filename="testimage.jpg"><dtml-var "testimage.data"></dtml-mime> </dtml-sendmail> Regards --- Flynt
Thank you Flynt, You have my permission to CC to the list at any time :) I e-mailed to you personally because I saw that you had the same problem I do, and I hoped that way I will get reply sooner. While I was waiting for you I played around and succeed to attach pdf document, but I cannot get right name (instead of name it gives me '-' ). Here is the code that I was using. <dtml-mime type=application/pdf encode=7bit> Attached is the document you requested. <dtml-boundary name=report.pdf type=application/pdf disposition=attachment encode=uuencode filename=report.pdf> <dtml-var expr="restrictedTraverse('report.pdf')"> </dtml-mime> I tried code you sent me and it gives me strange results. I tried testimage.data and got lots of gibberish, and than I tried testimage and got a little gibberish but not the image itself. Did I miss something? Vid --- Flynt <rhess@bic.ch> wrote:
zoops4@yahoo.com wrote:
Hi,
I am trying to send e-mail with attachment using
<dtml-sendmail>. I
noticed you had the same problem earlier, therefore I hope you can give me some suggestions. This is the code that I am using
First try:
<dtml-mime type=text/plain encode=7bit>
<dtml-boundary type=application/octet-stream disposition=attachment encode=base64> <dtml-var "selected_image.read()">
</dtml-mime>
first error:
Error Type: AttributeError Error Value: 'string' object has no attribute 'read'
Second try:
<dtml-mime type=text/plain encode=7bit>
<dtml-boundary type=application/octet-stream disposition=attachment encode=base64> <dtml-var "restrictedTraverse(selected_image).read()">
</dtml-mime>
Second Error:
Error Type: AttributeError Error Value: read
Thank you in ahead of time.
Vid
Hi Vid
(You mailed me personally, but I cc to the list with your permission ;-)
This code is working for me with documents and files (but not with images stored in the ZODB); I tried it with binary, pdf and html content.
<dtml-sendmail mailhost="MailHost"> From: <dtml-var sender> To: <dtml-var recipient> Date: <dtml-var ZopeTime fmt="rfc822"> Subject: Testmessage <dtml-mime type="text/plain" encode="7bit">
testmessage textbody
<dtml-boundary type="application/octet-stream" disposition="attachment" encode="base64" filename="testfile"><dtml-var testfile></dtml-mime> </dtml-sendmail>
Regards
--- Flynt
(Supplement)
Hi Vid
Here is the code, to send an image:
<dtml-sendmail mailhost="MailHost"> From: <dtml-var sender> To: <dtml-var recipient> Date: <dtml-var ZopeTime fmt="rfc822"> Subject: Testmessage <dtml-mime type="text/plain" encode="7bit">
testmessage textbody
<dtml-boundary type="application/octet-stream" disposition="attachment" encode="base64" filename="testimage.jpg"><dtml-var "testimage.data"></dtml-mime> </dtml-sendmail>
Regards
--- Flynt
_______________________________________________ Zope maillist - Zope@zope.org 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 )
__________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
Vid B wrote:
Thank you Flynt,
You have my permission to CC to the list at any time :)
I e-mailed to you personally because I saw that you had the same problem I do, and I hoped that way I will get reply sooner.
While I was waiting for you I played around and succeed to attach pdf document, but I cannot get right name (instead of name it gives me '-' ). Here is the code that I was using.
<dtml-mime type=application/pdf encode=7bit> Attached is the document you requested. <dtml-boundary name=report.pdf type=application/pdf disposition=attachment encode=uuencode filename=report.pdf> <dtml-var expr="restrictedTraverse('report.pdf')"> </dtml-mime>
I tried code you sent me and it gives me strange results. I tried testimage.data and got lots of gibberish, and than I tried testimage and got a little gibberish but not the image itself. Did I miss something?
Vid
Hi Vid I tried the DTML which I included in my answer to you, first for myself. And it did work for me (Zope 2.3.2 source release on Linux). So at that point it is difficult to say for me, why it doesn't work in your case. Maybe, some small item got overlooked, when you tried it, or, there are problems with your email client, or ... still something else. So I took your code above and tested it: Actually, I am a little bit surprised, that the first two lines of your code should work with you (it didn't for me):
<dtml-mime type=application/pdf encode=7bit> Attached is the document you requested. Here, you are sending text, but your type is application/pdf. Consequently I don't get the text message, when I try but only a faulty link to a MIME part. But this is easy: just change *type=application/pdf* to *type=text/plain*.
For the rest of your code: It is working. I get cleanly the pdf file with the rest of your code **including** the name *report.pdf* as attachment in my email viewer (Netscape). The problem of your missing name is not a problem of your code, but of something different (maybe it's in your email client). Note, that it is **not** a problem of encoding (as you suggested in an earlier mail): I tried your code above with uuencode _and_ with base64 and it works in both cases. Regards --- Flynt
participants (2)
-
Flynt -
Vid B