use of com.fsck.k9.mailstore.SaveMessageData in project k-9 by k9mail.
the class MessagingController method sendMessage.
/**
* Stores the given message in the Outbox and starts a sendPendingMessages command to attempt to send the message.
*/
public void sendMessage(Account account, Message message, String plaintextSubject, MessagingListener listener) {
try {
Long outboxFolderId = account.getOutboxFolderId();
if (outboxFolderId == null) {
if (BuildConfig.DEBUG) {
throw new AssertionError("Outbox does not exist");
}
Timber.w("Outbox does not exist");
outboxFolderId = specialLocalFoldersCreator.createOutbox(account);
}
message.setFlag(Flag.SEEN, true);
MessageStore messageStore = messageStoreManager.getMessageStore(account);
SaveMessageData messageData = saveMessageDataCreator.createSaveMessageData(message, MessageDownloadState.FULL, plaintextSubject);
long messageId = messageStore.saveLocalMessage(outboxFolderId, messageData, null);
LocalStore localStore = localStoreProvider.getInstance(account);
OutboxStateRepository outboxStateRepository = localStore.getOutboxStateRepository();
outboxStateRepository.initializeOutboxState(messageId);
sendPendingMessages(account, listener);
} catch (Exception e) {
Timber.e(e, "Error sending message");
}
}
Aggregations