1 # -*- coding: utf-8 -*-
3 # Send the same mail to a list of people, one at a time.
4 # As this is normal Python code, the message contents and
5 # the addresses could also come from an external source
6 # (such as a file, or a database).
7 addresses = ["mail1@example.tld", "mail2@example.tld", "mail3@example.tld"]
9 for address in addresses:
10 # The argument for the constructor is an email address on which
11 # the sending account is selected.
12 # It's also possible to use the default constructor without arguments,
13 # in which case the same rules as on a menu click one "New message"
15 cw = clawsmail.ComposeWindow("berndth@gmx.de")
17 # Add a recipient. There are also add_Cc and add_Bcc functions.
20 # Set the subject of the message
21 cw.set_subject("Mass mail")
23 # For the message body, access to the GtkTextView is granted in ComposeWindow.text.
24 buffer = cw.text.get_buffer()
25 buffer.set_text("This is an automatic message")
27 # Access to the GtkUIManager is also provided, look for "send later" action
29 for action_group in cw.ui_manager.get_action_groups():
30 for action in action_group.list_actions():
31 action = action_group.get_action("Message/SendLater")
39 # Finally, the action group of the main window can be used to send the messages out
40 # Comment this for now, to not actually send stuff during testing
41 #clawsmail.get_mainwindow_action_group().get_action("Message/SendQueue").activate()