diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/internet/MimeMessage.java b/k9mail-library/src/main/java/com/fsck/k9/mail/internet/MimeMessage.java index 632018c29..981e441a1 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/internet/MimeMessage.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/internet/MimeMessage.java @@ -308,13 +308,10 @@ public class MimeMessage extends Message { if (mMessageId == null) { mMessageId = getFirstHeader("Message-ID"); } - if (mMessageId == null) { // even after checking the header - setMessageId(generateMessageId()); - } return mMessageId; } - private String generateMessageId() { + public void generateMessageId() throws MessagingException { String hostname = null; if (mFrom != null && mFrom.length >= 1) { @@ -330,7 +327,9 @@ public class MimeMessage extends Message { } /* We use upper case here to match Apple Mail Message-ID format (for privacy) */ - return "<" + UUID.randomUUID().toString().toUpperCase(Locale.US) + "@" + hostname + ">"; + String messageId = "<" + UUID.randomUUID().toString().toUpperCase(Locale.US) + "@" + hostname + ">"; + + setMessageId(messageId); } public void setMessageId(String messageId) throws MessagingException { diff --git a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java index 0129b82e1..31b87dfd8 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java @@ -1338,6 +1338,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, private MimeMessage createMessage(boolean isDraft) throws MessagingException { MimeMessage message = new MimeMessage(); message.addSentDate(new Date(), K9.hideTimeZone()); + message.generateMessageId(); Address from = new Address(mIdentity.getEmail(), mIdentity.getName()); message.setFrom(from); message.setRecipients(RecipientType.TO, getAddresses(mToView)); diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalFolder.java b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalFolder.java index 37f969108..9dfb0f51b 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalFolder.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalFolder.java @@ -1179,6 +1179,10 @@ public class LocalFolder extends Folder implements Serializable { } private ThreadInfo getThreadInfo(SQLiteDatabase db, String messageId, boolean onlyEmpty) { + if (messageId == null) { + return null; + } + String sql = "SELECT t.id, t.message_id, t.root, t.parent " + "FROM messages m " + "LEFT JOIN threads t ON (t.message_id = m.id) " + @@ -1393,8 +1397,6 @@ public class LocalFolder extends Folder implements Serializable { @Override public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException { try { - message.buildMimeRepresentation(); - ViewableContainer container = LocalMessageExtractor.extractTextAndAttachments(LocalFolder.this.localStore.context, message);