Thunderbird -compose - command line Python

User Help for Mozilla Thunderbird
Post Reply
Eldritch
Posts: 2
Joined: June 13th, 2019, 8:36 am

Thunderbird -compose - command line Python

Post by Eldritch »

I`m trying to create Thunderbird email messages from command line using Python. The emails very often would have more one item in a field (for instance, two email adressess cc or two files attatched).

I have found the following info:
Watch out for the somewhat complex syntax of the "-compose" command-line option. The double-quotes enclose the full comma-separated list of arguments passed to "-compose", whereas single quotes are used to group items for the same argument. Example:

thunderbird -compose "to='john@example.com,kathy@example.com',cc='britney@example.com',subject='dinner',body='How about dinner tonight?',attachment='C:\temp\info.doc,C:\temp\food.doc'"
I have managed to create a working version:

Code: Select all

import webbrowser, os

from urllib.parse import quote

body = """Some text,

Bla bla bla. Text."""

recipient = 'address1@mail.com'

cc = 'address2@mail.com,address3@mail.com'

subject = 'Title of the mail'

attatchment = 'C:\ABC\\DE\\FGH\\IJK.pdf'

os.system("thunderbird -compose to=" + recipient +",cc= 'address2@mail.com,address3@mail.com' ,subject=" + quote(subject) + ",body=" + quote(body) + ",attachment=" + attatchment +"\"")

However, if I substitute 'address2@mail.com,address3@mail.com' for cc variable (which contains those two cc email addresses):

Code: Select all

os.system("thunderbird -compose to=" + recipient + ",cc=" + cc + ",subject=" + quote(subject) + ",body=" + quote(body) + ",attachment=" + attatchment + "\"")
The mail is created but without the second cc address.



Any idea how to fix that?
morat
Posts: 6425
Joined: February 3rd, 2009, 6:29 pm

Re: Thunderbird -compose - command line Python

Post by morat »

Eldritch
Posts: 2
Joined: June 13th, 2019, 8:36 am

Re: Thunderbird -compose - command line Python

Post by Eldritch »

Morat! Thank you!
Post Reply