Don't crash on bad eml files. b/12066982.

Change-Id: I174f6a341f9ee47b1e95c74ef48ac0fdf6332860
diff --git a/src/com/android/mail/providers/Message.java b/src/com/android/mail/providers/Message.java
index 792ed12..8bd8469 100644
--- a/src/com/android/mail/providers/Message.java
+++ b/src/com/android/mail/providers/Message.java
@@ -44,6 +44,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 import java.util.regex.Pattern;
 
@@ -376,7 +377,16 @@
                 com.android.emailcommon.mail.Message.RecipientType.BCC)));
         setReplyTo(com.android.emailcommon.mail.Address.pack(mimeMessage.getReplyTo()));
         subject = mimeMessage.getSubject();
-        dateReceivedMs = mimeMessage.getSentDate().getTime();
+
+        final Date sentDate = mimeMessage.getSentDate();
+        final Date internalDate = mimeMessage.getInternalDate();
+        if (sentDate != null) {
+            dateReceivedMs = sentDate.getTime();
+        } else if (internalDate != null) {
+            dateReceivedMs = internalDate.getTime();
+        } else {
+            dateReceivedMs = System.currentTimeMillis();
+        }
 
         // for now, always set defaults
         alwaysShowImages = false;