-
- TnyAccount *account = NULL;
- if (account_name && account_mgr) {
- account = modest_tny_account_store_get_transport_account_for_open_connection (
- modest_runtime_get_account_store(), account_name);
- }
-
- if (!account) {
- g_printerr ("modest: failed to get tny account folder'%s'\n", account_name);
- } else {
- gchar * from = modest_account_mgr_get_from_string (account_mgr,
- account_name);
- if (!from) {
- g_printerr ("modest: no from address for account '%s'\n", account_name);
- } else {
- /* Get the signature.
- * TODO: This, like much of this function is copy/pasted from
- * modest_ui_actions_on_new_msg(): */
- gboolean use_signature = FALSE;
- gchar *signature = modest_account_mgr_get_signature (modest_runtime_get_account_mgr (), account_name, &use_signature);
-
- gchar* blank_and_signature = NULL;
- if (use_signature) {
- blank_and_signature = g_strconcat ("\n", signature, NULL);
- } else {
- blank_and_signature = g_strdup ("");
- }
- g_free (signature);
-
- /* Add it to the body. */
- gchar *body_with_sig = NULL;
- if (!(idle_data->body))
- body_with_sig = g_strdup (blank_and_signature);
- else {
- body_with_sig = g_strconcat (idle_data->body, blank_and_signature, NULL);
- }
-
- /* Create the message: */
- TnyMsg *msg = modest_tny_msg_new (idle_data->to, from,
- idle_data->cc, idle_data->bcc, idle_data->subject, body_with_sig,
- NULL); /* NULL because m_t_m_n doesn't use it */
-
- g_free (body_with_sig);
- g_free (blank_and_signature);
-
- if (!msg) {
- g_printerr ("modest: failed to create message\n");
- } else
- {
- /* Add the message to a folder and show its UI for editing: */
- TnyFolder *folder = modest_tny_account_get_special_folder (account,
- TNY_FOLDER_TYPE_DRAFTS);
- if (!folder) {
- g_printerr ("modest: failed to find Drafts folder\n");
- } else {
-
- tny_folder_add_msg (folder, msg, NULL); /* TODO: check err */