def mailto_url(to=None,subject=None,body=None,cc=None):
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:
body="\r\n".join(body.splitlines())
url+= sep + "body=" + urllib.quote(body,"")
sep = "&"
return url
import urllib
import webbrowser
url = mailto_url('email address', 'subject', 'message body')
webbrowser.open(url,new=1)
我有上面的代码来显示默认的电子邮件客户端。但我需要自动发送电子邮件。有没有办法使用脚本按下“发送”按钮?