[Zope] File Attachment Again....

SERVEL Yannick SERVELYM@cardiff.ac.uk
Thu, 29 Apr 1999 16:47:42 +0100


------=_NextPart_000_004B_01BE925F.FFFFDFA0
Content-type: text/plain; charset="iso-8859-1"
Content-transfer-encoding: quoted-printable

Hi everybody.

I am meeting several problems about the creation of the file =
attachment...

Here is the Send_Mail dtml document

<!--#var standard_html_header-->

<!--#var file-->

<!--#var =
"Smtp_send_func(smtp_server=3DDomain_Name,tolist=3D[support],msg=3Dbody,s=
ubject=3Dsubject,fromme=3Dfromme,file=3Dfile,REQUEST=3DREQUEST)"-->
<br>

<CENTER><H1>Message Sent</H1>
<br>
<a href=3D"S_Compose_Mail?Domain_Name=3D<!--#var =
Domain_Name-->&login=3D<!--#var login-->"><IMG SRC=3D"back" =
border=3D0></a></CENTER>=20

<!--#var standard_html_footer-->

And here is the python smtp.py source file:

def =
smtp_send(self,smtp_server=3DNone,tolist=3DNone,msg=3DNone,subject=3DNone=
,fromme=3DNone,file=3D'',REQUEST=3DNone):
	smtp=3Dsmtplib.SMTP(smtp_server)
	msg=3D"Subject: " + subject + "\n\r" +msg
	smtp.sendmail(fromme,tolist,msg)
	smtp.quit()
	s=3D''
=09
	s=3Ds+file.read()
        return s

But it deosn't work...

<HTML><HEAD><TITLE>yannick</TITLE></HEAD><BODY BGCOLOR=3D"#FFFFFF">
<TABLE BORDER=3D"0" WIDTH=3D"100%">
<TR>
  <TD WIDTH=3D"10%" ALIGN=3D"CENTER">
  <STRONG><FONT SIZE=3D"+6" COLOR=3D"#77003B">!</FONT></STRONG>
  </TD>
  <TD WIDTH=3D"90%"><BR>
  <FONT SIZE=3D"+2">System Unavailable</FONT>
  <P>This site is currently experiencing technical difficulties.=20
Please contact the site administrator for more information.  For
additional technical information, please refer to the HTML source for =
this
page.  Thank you for your patience.</P>
  </TD>
</TR>
</TABLE>
<!--
 Error type: =20
 Error value: read-only buffer, class
 -->
</BODY></HTML>
<!--
Traceback (innermost last):
  File C:\Program Files\servel\lib\python\ZPublisher\Publish.py, line =
877, in publish_module
  File C:\Program Files\servel\lib\python\ZPublisher\Publish.py, line =
590, in publish
    (Info: /servel/Send_Mail)
  File C:\Program Files\servel\lib\python\OFS\DTMLDocument.py, line 212, =
in __call__
    (Object: Send_Mail)
  File C:\Program Files\servel\lib\python\OFS\DTMLDocument.py, line 208, =
in __call__
    (Object: Send_Mail)
  File C:\Program Files\servel\lib\python\DocumentTemplate\DT_String.py, =
line 513, in __call__
    (Object: Send_Mail)
  File C:\Program Files\servel\lib\python\DocumentTemplate\DT_Util.py, =
line 266, in eval
    (Object: =
Smtp_send_func(smtp_server=3DDomain_Name,tolist=3D[support],msg=3Dbody,su=
bject=3Dsubject,fromme=3Dfromme,file=3Dfile,REQUEST=3DREQUEST))
  File &lt;string&gt;, line 0, in ?
  File C:\Program =
Files\servel\lib\python\Products\ExternalMethod\ExternalMethod.py, line =
254, in __call__
    (Object: CopySource)
    (Info: ((), {'subject': '&quot;Et maintenant admire la puissante de =
feu de ma STATION&quot;', 'smtp_server': 'd032.ml.ucwm.ac.uk', =
'REQUEST': form:
	subject: '&quot;Et maintenant admire la puissante de feu de ma =
STATION&quot;'
	Domain_Name: 'd032.ml.ucwm.ac.uk'
	support: 'wmlyms'
	file: &lt;ZPublisher.Publish.FileUpload instance at 964fc20&gt;
	login: 'wmlyms'
	fromme: 'ah@serveland.com'
	body: '  we'


environ:
	HTTP_ACCEPT_ENCODING: 'gzip, deflate'
	REMOTE_HOST: 'localhost'
	PATH_INFO: '/servel/Send_Mail'
	CONTENT_LENGTH: '1217'
	SERVER_PROTOCOL: 'HTTP/1.0'
	CONTENT_TYPE: 'multipart/form-data; =
boundary=3D---------------------------7cf3bda36301c0'
	PATH_TRANSLATED: =
'C:\\NT\\Profiles\\wmlyms.000\\Desktop\\servel\\Send_Mail'
	HTTP_HOST: 'localhost:9673'
	REQUEST_METHOD: 'POST'
	HTTP_COOKIE: 'dtpref_rows=3D&quot;25&quot;; =
dtpref_cols=3D&quot;90&quot;; tree-s=3D&quot;eJyLjjaMjQUABOIBog&quot;'
	SCRIPT_NAME: ''
	SERVER_SOFTWARE: 'ZopeHTTP/1.16 Python/1.5.1'
	HTTP_ACCEPT_LANGUAGE: 'en-us'
	HTTP_ACCEPT: 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, =
application/msword, application/vnd.ms-excel, =
application/vnd.ms-powerpoint, */*'
	GATEWAY_INTERFACE: 'CGI/1.1'
	SERVER_PORT: '9673'
	SERVER_NAME: 'media10.ml.uwcm.ac.uk'
	HTTP_CONNECTION: 'Keep-Alive'
	HTTP_USER_AGENT: 'Mozilla/4.0 (compatible; MSIE 5.0b2; Windows NT)'
	REMOTE_ADDR: '127.0.0.1'
	HTTP_REFERER: =
'http://localhost:9673/servel/S_Compose_Mail?Domain_Name=3Dd032.ml.uwcm.a=
c.uk&amp;login=3Dwmlyms'


, 'msg': '  we', 'file': &lt;ZPublisher.Publish.FileUpload instance at =
964fc20&gt;, 'fromme': 'ah@serveland.com', 'tolist': ['wmlyms']}, (None, =
None, None, None, None, '', None)))
TypeError: (see above)

-->

If you have managed to read everything, thanks for your patience...


P.S Many thanks for the help I were provided before

------=_NextPart_000_004B_01BE925F.FFFFDFA0
Content-type: text/html; charset="iso-8859-1"
Content-transfer-encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML><HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<STYLE></STYLE>

<META content=3D'"MSHTML 5.00.0910.1309"' name=3DGENERATOR></HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2><STRONG>Hi =
everybody.</STRONG></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>I am meeting several problems =
about the=20
creation of the file attachment...</STRONG></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Here is the Send_Mail dtml=20
document</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;!--#var =
standard_html_header--&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;!--#var file--&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;!--#var=20
&quot;Smtp_send_func(smtp_server=3DDomain_Name,tolist=3D[support],msg=3Db=
ody,subject=3Dsubject,fromme=3Dfromme,file=3Dfile,REQUEST=3DREQUEST)&quot=
;--&gt;<BR>&lt;br&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;CENTER&gt;&lt;H1&gt;Message=20
Sent&lt;/H1&gt;<BR>&lt;br&gt;<BR>&lt;a=20
href=3D&quot;S_Compose_Mail?Domain_Name=3D&lt;!--#var=20
Domain_Name--&gt;&amp;login=3D&lt;!--#var login--&gt;&quot;&gt;&lt;IMG=20
SRC=3D&quot;back&quot; border=3D0&gt;&lt;/a&gt;&lt;/CENTER&gt; =
</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;!--#var =
standard_html_footer--&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>And here is the python smtp.py =
source=20
file:</STRONG></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>def=20
smtp_send(self,smtp_server=3DNone,tolist=3DNone,msg=3DNone,subject=3DNone=
,fromme=3DNone,file=3D'',REQUEST=3DNone):<BR>	=
smtp=3Dsmtplib.SMTP(smtp_server)<BR>	msg=3D&quot;Subject:=20
&quot; + subject + &quot;\n\r&quot;=20
+msg<BR>	smtp.sendmail(fromme,tolist,msg)<BR>	smtp.quit()<BR>	s=3D''<BR>	=
<BR>	s=3Ds+file.read()<BR>=20
       return s</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>But it deosn't=20
work...</STRONG></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;yannick&lt;/TITLE&gt;&lt;/H=
EAD&gt;&lt;BODY=20
BGCOLOR=3D&quot;#FFFFFF&quot;&gt;<BR>&lt;TABLE BORDER=3D&quot;0&quot;=20
WIDTH=3D&quot;100%&quot;&gt;<BR>&lt;TR&gt;<BR>  &lt;TD =
WIDTH=3D&quot;10%&quot;=20
ALIGN=3D&quot;CENTER&quot;&gt;<BR>  &lt;STRONG&gt;&lt;FONT =
SIZE=3D&quot;+6&quot;=20
COLOR=3D&quot;#77003B&quot;&gt;!&lt;/FONT&gt;&lt;/STRONG&gt;<BR>  =
&lt;/TD&gt;<BR> =20
&lt;TD WIDTH=3D&quot;90%&quot;&gt;&lt;BR&gt;<BR>  &lt;FONT=20
SIZE=3D&quot;+2&quot;&gt;System Unavailable&lt;/FONT&gt;<BR>  =
&lt;P&gt;This site=20
is currently experiencing technical difficulties. <BR>Please contact the =
site=20
administrator for more information.  For<BR>additional technical =
information,=20
please refer to the HTML source for this<BR>page.  Thank you for your=20
patience.&lt;/P&gt;<BR> =20
&lt;/TD&gt;<BR>&lt;/TR&gt;<BR>&lt;/TABLE&gt;<BR>&lt;!--<BR> Error type:  =
<BR>=20
Error value: read-only buffer, class<BR>=20
--&gt;<BR>&lt;/BODY&gt;&lt;/HTML&gt;<BR>&lt;!--<BR>Traceback (innermost=20
last):<BR>  File C:\Program =
Files\servel\lib\python\ZPublisher\Publish.py, line=20
877, in publish_module<BR>  File C:\Program=20
Files\servel\lib\python\ZPublisher\Publish.py, line 590, in publish<BR>  =
 =20
(Info: /servel/Send_Mail)<BR>  File C:\Program=20
Files\servel\lib\python\OFS\DTMLDocument.py, line 212, in __call__<BR>   =
=20
(Object: Send_Mail)<BR>  File C:\Program=20
Files\servel\lib\python\OFS\DTMLDocument.py, line 208, in __call__<BR>   =
=20
(Object: Send_Mail)<BR>  File C:\Program=20
Files\servel\lib\python\DocumentTemplate\DT_String.py, line 513, in =
__call__<BR>=20
   (Object: Send_Mail)<BR>  File C:\Program=20
Files\servel\lib\python\DocumentTemplate\DT_Util.py, line 266, in =
eval<BR>   =20
(Object:=20
Smtp_send_func(smtp_server=3DDomain_Name,tolist=3D[support],msg=3Dbody,su=
bject=3Dsubject,fromme=3Dfromme,file=3Dfile,REQUEST=3DREQUEST))<BR>=20
 File &amp;lt;string&amp;gt;, line 0, in ?<BR>  File C:\Program=20
Files\servel\lib\python\Products\ExternalMethod\ExternalMethod.py, line =
254, in=20
__call__<BR>    (Object: CopySource)<BR>    (Info: ((), {'subject':=20
'&amp;quot;Et maintenant admire la puissante de feu de ma =
STATION&amp;quot;',=20
'smtp_server': 'd032.ml.ucwm.ac.uk', 'REQUEST': form:<BR>	subject: =
'&amp;quot;Et=20
maintenant admire la puissante de feu de ma STATION&amp;quot;'<BR>	=
Domain_Name:=20
'd032.ml.ucwm.ac.uk'<BR>	support: 'wmlyms'<BR>	file:=20
&amp;lt;ZPublisher.Publish.FileUpload instance at 964fc20&amp;gt;<BR>	=
login:=20
'wmlyms'<BR>	fromme: <A=20
href=3D"mailto:'ah@serveland.com'">'ah@serveland.com'</A><BR>	body: ' =20
we'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>environ:<BR>	HTTP_ACCEPT_ENCODING: =
'gzip,=20
deflate'<BR>	REMOTE_HOST: 'localhost'<BR>	PATH_INFO:=20
'/servel/Send_Mail'<BR>	CONTENT_LENGTH: '1217'<BR>	SERVER_PROTOCOL:=20
'HTTP/1.0'<BR>	CONTENT_TYPE: 'multipart/form-data;=20
boundary=3D---------------------------7cf3bda36301c0'<BR>	=
PATH_TRANSLATED:=20
'C:\\NT\\Profiles\\wmlyms.000\\Desktop\\servel\\Send_Mail'<BR>	=
HTTP_HOST:=20
'localhost:9673'<BR>	REQUEST_METHOD: 'POST'<BR>	HTTP_COOKIE:=20
'dtpref_rows=3D&amp;quot;25&amp;quot;; =
dtpref_cols=3D&amp;quot;90&amp;quot;;=20
tree-s=3D&amp;quot;eJyLjjaMjQUABOIBog&amp;quot;'<BR>	SCRIPT_NAME:=20
''<BR>	SERVER_SOFTWARE: 'ZopeHTTP/1.16 Python/1.5.1'<BR>	=
HTTP_ACCEPT_LANGUAGE:=20
'en-us'<BR>	HTTP_ACCEPT: 'image/gif, image/x-xbitmap, image/jpeg, =
image/pjpeg,=20
application/msword, application/vnd.ms-excel, =
application/vnd.ms-powerpoint,=20
*/*'<BR>	GATEWAY_INTERFACE: 'CGI/1.1'<BR>	SERVER_PORT: '9673'<BR>	=
SERVER_NAME:=20
'media10.ml.uwcm.ac.uk'<BR>	HTTP_CONNECTION: 'Keep-Alive'<BR>	=
HTTP_USER_AGENT:=20
'Mozilla/4.0 (compatible; MSIE 5.0b2; Windows NT)'<BR>	REMOTE_ADDR:=20
'127.0.0.1'<BR>	HTTP_REFERER:=20
'http://localhost:9673/servel/S_Compose_Mail?Domain_Name=3Dd032.ml.uwcm.a=
c.uk&amp;amp;login=3Dwmlyms'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>, 'msg': '  we', 'file':=20
&amp;lt;ZPublisher.Publish.FileUpload instance at 964fc20&amp;gt;, =
'fromme': <A=20
href=3D"mailto:'ah@serveland.com'">'ah@serveland.com'</A>, 'tolist': =
['wmlyms']},=20
(None, None, None, None, None, '', None)))<BR>TypeError: (see=20
above)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>--&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>If you have managed to read =
everything,=20
thanks for your patience...</STRONG></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>P.S Many thanks for the help I =
were=20
provided before</STRONG></FONT></DIV></BODY></HTML>

------=_NextPart_000_004B_01BE925F.FFFFDFA0--