In article <[EMAIL PROTECTED]>, Cameron Laird <[EMAIL PROTECTED]> wrote:
>In article <[EMAIL PROTECTED]>,
>[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>>Hello,
>>
>>the simplest way to launch the user's standard mail client from a
>>Python program is by creating a mailto: URL and launching the
>>webbrowser:
>>
>>def mailto_url(to=None,subject=None,body=None,cc=None):
>>    """
>>    encodes the content as a mailto link as described on
>>    http://www.faqs.org/rfcs/rfc2368.html
>>    Examples partly taken from
>>    http://selfhtml.teamone.de/html/verweise/email.htm
>>    """
>>    url = "mailto:"; + urllib.quote(to.strip(),"@,")
>>    sep = "?"
>>    if cc:
>>        url+= sep + "cc=" + urllib.quote(cc,"@,")
>>        sep = "&"
>>    if subject:
>>        url+= sep + "subject=" + urllib.quote(subject,"")
>>        sep = "&"
>>    if body:
>>        # Also note that line breaks in the body of a message MUST be
>>        # encoded with "%0D%0A". (RFC 2368)
>>        body="\r\n".join(body.splitlines())
>>        url+= sep + "body=" + urllib.quote(body,"")
>>        sep = "&"
>>    return url
>>
>>import webbrowser
>>url = mailto_url(...)
>>webbrowser.open(url,new=1)
>>
>>(Excerpt from
>>http://svn.berlios.de/wsvn/lino/trunk/src/lino/tools/mail.py?op=file&rev=0&sc=0)
>>
>>But this method is limited: you cannot specify a file to be attached
>>to the mail. And I guess that there would be problems if the body text
>>is too complex.
>>
>>Does somebody know about a better method?
>>It should be possible at least on Windows, since Acrobat Reader is
>>able to do it.
>                       .
>                       .
>                       .
>Portland <URL:
>http://ct.enews.eweek.com/rd/cts?d=186-6281-53-799-798304-697089-0-0-0-1 >
>is the best standardization of this problem we have under Linux.
>
>I'll address Windows in a subsequent follow-up.

A.  Apologies!  I'm sorry about the URL above; it was
    completely wrong.  I intended <URL:
    http://www-128.ibm.com/developerworks/linux/library/l-portland.html >.
B.  The best approach I know under Windows is to invoke
            start mailto:$ADDRESS
    1.  That invocation does *not* communicate
        subject, attachments, ...  To do so 
        adequately involves application-specific
        work, as other follow-ups have mentioned.
    2.  "start" has its own complexities.  The
        best invocation from console-based Python
        is likely to be 
            start /w "" mailto:$ADDRESS
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to