Just for interest...[off topic but stuff people using a GUI package would
fairly commonly want to do I imagine]
I finally sorted out the matter of starting a mailer with a given subject
and body... part of my code follows...
import webbrowser
def _startmailerwithhtml(mailto,subject,html,text=None,mailfrom=None):
if sys.hexversion >= 0x02000000:#\
s = 'mailto:%s?subject=%s&body=%s' % (mailto,
urllib.quote(subject),
urllib.quote(
string.replace(text,'\n','\r\n'),
""))
# Note that RFC 2368 requires that line breaks in the body of
# a message contained in a mailto URL MUST be encoded with
# "%0D%0A"--even on Unix/Linux. Also note that there appears
# to be no way to specify that the body of a mailto tag be
# interpreted as HTML (mailto tags shouldn't stuff around with
# the MIME-Version/Content-Type headers, the RFC says, so I
# can't even be bothered trying, as the Python
# webbrowser/urllib modules quite likely won't allow
# this... anyway, a plain text message is [at least!] fine...)
webbrowser.open(s)
return 1
else:
return _writehtmlmessage(mailto,subject,html,text,mailfrom=mailfrom)
Thanks for all your helpful suggestions.
Cheerio, Chris
···
-------------------------------------------------------------------------
Chris Fama <mailto:Chris.Fama@whollysnakes.com>
or <mailto:Chris.Fama@uq.net.au>
Brisbane, Australia
Phone: (0/+61)(7) 3870 5639 {10am-10pm GMT+10 on both these numbers please}
Mobile: (0/+61)(400) 833 700
-------------------------------------------------------------------------
Business page: <http://whollysnakes.com>
Personal page: <http://uq.net.au/~zzcfama>
-------------------------------------------------------------------------
If you aren't certain what type of line endings might occur in the text
argument, you may want to generalize your line ending replacement like this:
lines = text.split('\r\n')
for l in range(len(lines)):
chunks = lines[l].split('\r')
for c in range(len(chunks)):
chunks[c] = '\r\n'.join(chunks[c].split('\n'))
lines[l] = '\r\n'.join(chunks)
text = '\r\n'.join(lines)
···
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."
-----Original Message-----
From: wxpython-users-admin@lists.wxwindows.org
[mailto:wxpython-users-admin@lists.wxwindows.org]On Behalf Of Chris Fama
Sent: Thursday, November 08, 2001 3:42 AM
To: wxPython-users mailing list
Subject: [wxPython] OT: starting mailer
Just for interest...[off topic but stuff people using a GUI package would
fairly commonly want to do I imagine]
I finally sorted out the matter of starting a mailer with a given subject
and body... part of my code follows...
import webbrowser
def _startmailerwithhtml(mailto,subject,html,text=None,mailfrom=None):
if sys.hexversion >= 0x02000000:#\
s = 'mailto:%s?subject=%s&body=%s' % (mailto,
urllib.quote(subject),
urllib.quote(
string.replace(text,'\n','\r\n'),
""))
# Note that RFC 2368 requires that line breaks in the body of
# a message contained in a mailto URL MUST be encoded with
# "%0D%0A"--even on Unix/Linux. Also note that there appears
# to be no way to specify that the body of a mailto tag be
# interpreted as HTML (mailto tags shouldn't stuff around with
# the MIME-Version/Content-Type headers, the RFC says, so I
# can't even be bothered trying, as the Python
# webbrowser/urllib modules quite likely won't allow
# this... anyway, a plain text message is [at least!] fine...)
webbrowser.open(s)
return 1
else:
return _writehtmlmessage(mailto,subject,html,text,mailfrom=mailfrom)
Thanks for all your helpful suggestions.
Cheerio, Chris
-------------------------------------------------------------------------
Chris Fama <mailto:Chris.Fama@whollysnakes.com>
or <mailto:Chris.Fama@uq.net.au>
Brisbane, Australia
Phone: (0/+61)(7) 3870 5639 {10am-10pm GMT+10 on both these numbers please}
Mobile: (0/+61)(400) 833 700
-------------------------------------------------------------------------
Business page: <http://whollysnakes.com>
Personal page: <http://uq.net.au/~zzcfama>
-------------------------------------------------------------------------
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users