mailto: URL syntax
"mailto:" recipients ( "?" key "=" value ("&" key "=" value)* )?
- recipients: comma-separated email addresses (no spaces; Outlook needs semicolons instead of commas)
- value: should be URL-encoded (e.g. space becomes %20)
- key: subject, cc, bcc, body
- Example: mailto:joe@example.com,jane@example.com?subject=hello&body=How%20are%20you%3F
Open mailto URLs with Python
#!/usr/bin/python
from urllib import quote
import webbrowser
def mailto(recipients, subject, body):
"recipients: string with comma-separated emails (no spaces!)"
webbrowser.open("mailto:%s?subject=%s&body=%s" %
(recipients, quote(subject), quote(body)))
body_template = """Hello %(name)s!
How are you?"""
def gen(email, name):
mailto(email, "Hi!", body_template % locals())
gen("joe@example.com", "Joe")
gen("jane@example.com,jill@example.com", "Jane and Jill")
Related:
Flattr
ليست هناك تعليقات:
إرسال تعليق