On 30/07/2019 10.06, dmitre...@gmail.com wrote:
> Hello,
>
> is Python capable of generating a email form (from standard data - address, 
> topic, string message) with raising it by a default OS email client, e.g. 
> Thunderbird? User would like to have a possibility to review/modify email 
> content inside the OS email client window before sending it.
>
> Raising gmail.com GUI form also could be a solution.
>
> Thank you in advance, D.

You could construct a mailto URI

https://en.wikipedia.org/wiki/Mailto

>>>> subject = 'This is the subject'
>>> body = 'This is the text'
>>> to = 'g...@heaven.example.com'
>>> cc = 'friedrich.nietzs...@unibas.ch'
>> mailto_url = urllib.parse.quote(f'mailto:{to}?') +
urllib.parse.urlencode({'cc': cc, 'subject': subject, 'body': body},
quote_via=urllib.parse.quote)

If you open that URI with the webbrowser module, it should work. Well,
it might. On my system, Chrome refuses to open a mailto URI like this,
but Firefox plays along.

The better option would be to call the mail program directly (such as
using the subprocess module), but how you find out what to call will
depend on your OS. If this is just for one PC and you use Thunderbird,
then you might as well hard-code the Thunderbird executable, of course...



-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to