+
+
+
+static int
+send_mail (ModestConf *conf, const gchar* mailto, const gchar *cc, const gchar *bcc,
+ const gchar* subject, const gchar *body)
+{
+ ModestAccountMgr *acc_mgr = NULL;
+ ModestTnyTransportActions *transport = NULL;
+ ModestTnyAccountStore *acc_store = NULL;
+
+ TnyListIface *accounts = NULL;
+ TnyIteratorIface *iter = NULL;
+ TnyTransportAccountIface *account = NULL;
+ int retval;
+
+ acc_mgr = modest_account_mgr_new (conf);
+ acc_store = modest_tny_account_store_new (acc_mgr);
+ transport = modest_tny_transport_actions_new ();
+
+ accounts = TNY_LIST_IFACE(tny_list_new ());
+ tny_account_store_iface_get_accounts (TNY_ACCOUNT_STORE_IFACE(acc_store), accounts,
+ TNY_ACCOUNT_STORE_IFACE_TRANSPORT_ACCOUNTS);
+
+ iter = tny_list_iface_create_iterator(accounts);
+ tny_iterator_iface_first (iter);
+ if (tny_iterator_iface_is_done (iter)) {
+ g_printerr("modest: no transport accounts defined\n");
+ retval = MODEST_ERR_SEND;
+ goto cleanup;
+ }
+
+ account = TNY_TRANSPORT_ACCOUNT_IFACE (tny_iterator_iface_current(iter));
+
+ if (!modest_tny_transport_actions_send_message (transport, account,
+ "<>", mailto, cc, bcc, subject, body,
+ NULL)) {
+ retval = MODEST_ERR_SEND;
+ goto cleanup;
+ } else
+ retval = MODEST_ERR_NONE; /* hurray! */
+
+cleanup:
+ if (iter)
+ g_object_unref (G_OBJECT(iter));
+ if (accounts)
+ g_object_unref (G_OBJECT(accounts));
+ if (transport)
+ g_object_unref (G_OBJECT(transport));
+ if (acc_store)
+ g_object_unref (G_OBJECT(acc_store));
+ if (acc_mgr)
+ g_object_unref (G_OBJECT(acc_mgr));
+
+ return retval;
+}
+