Code Monkey home page Code Monkey logo

Comments (14)

DenBond7 avatar DenBond7 commented on July 24, 2024

f14e433
c7a432e

from flowcrypt-android.

DenBond7 avatar DenBond7 commented on July 24, 2024

I tried to use your code for parse raw MIME message. And I have some issues.

  1. The file raw_mime_html.txt not parsed correctly. I received mimeMessage.getText() == null. Can you see what the problem is?

  2. If you do not mind, I would like to make the word "date, subject, from, to" as String constants in class com.flowcrypt.email.test.MimeMessage

  3. Can you add the ability to receive dates in timestamp variant (for example 1493972679000)? When I use JavaMail, I received a message date as a Date object. In this case, I can display time in a format convenient for the user, according to his preferences. If I have a timestamp, I can create a Date object manually.

from flowcrypt-android.

DenBond7 avatar DenBond7 commented on July 24, 2024

346f5de

from flowcrypt-android.

tomholub avatar tomholub commented on July 24, 2024

from flowcrypt-android.

tomholub avatar tomholub commented on July 24, 2024

from flowcrypt-android.

DenBond7 avatar DenBond7 commented on July 24, 2024

Does getHtml() also return null?

No, getHtml() return String.
You can see the screenshot.
2017-05-05_11-12-58

from flowcrypt-android.

tomholub avatar tomholub commented on July 24, 2024

There you go - this MIME message only contains HTML but no plain text.

This is correct behavior. if message.getText() == null, then you display message.getHtml()

from flowcrypt-android.

tomholub avatar tomholub commented on July 24, 2024

from flowcrypt-android.

tomholub avatar tomholub commented on July 24, 2024

from flowcrypt-android.

DenBond7 avatar DenBond7 commented on July 24, 2024

Ok, then I'll change the code according to the comments

from flowcrypt-android.

tomholub avatar tomholub commented on July 24, 2024

To answer your questions that I didn't address above:

  1. You can change MimeMessage or other classes to your liking. A string constant may make sense for title (although a getter may be better, eg mm.getTitle() - up to you). You could also have a Long for date under mm.getDate() or just mm.date etc. But to is more complicated - there may be 5 people that the message was sent to. Each person has an email and a name. How do you want to represent it in a string constant? Same thing for from - there is an email and a name as well, one string may not be sufficient. That's why I thought MimeAddress may be a good way to approach it. Let me know what you think, I'm not really a Java person :)

  2. That is a good idea. I have added this functionality now, you can use it as follows:

MimeMessage m = js.mime_decode(read(context.getAssets().open("sample/message.mime")));
System.out.println("Date:" + m.getTimeHeader("date"));

which will print out Date:1493133431000. This is UTC time (amount of milliseconds from the epoch), so you will still need to convert it to local timezone.

from flowcrypt-android.

DenBond7 avatar DenBond7 commented on July 24, 2024
  1. In this case, I mean for example mimeMessage.getAddressHeader(MimeMessage.HEADER_NAME_FROM) instead mimeMessage.getAddressHeader("from"). In Java it is considered a bad practice to write String in the code that can be used more than once. Therefore, they are rendered into constants to reduce the probability of writing a wrong String (for example with missing chars etc.).

public static final String HEADER_NAME_FROM= "from";

  1. Very good! I applied this code. It works perfectly.

123573a

I close this task. I have no more questions.

from flowcrypt-android.

tomholub avatar tomholub commented on July 24, 2024

Good work!

Yes I thought it may be a bad practice in Java.
mimeMessage.getAddressHeader(MimeMessage.HEADER_NAME_FROM) is perfectly fine and makes sense for the use case, although a bit long :)

Maybe a special class MimeHeader that will just have the constants. Used this way:
mimeMessage.getAddressHeader(MimeHeader.FROM)
mimeMessage.getAddressHeader(MimeHeader.TO)
mimeMessage.getAddressHeader(MimeHeader.SUBJECT)

etc

from flowcrypt-android.

DenBond7 avatar DenBond7 commented on July 24, 2024

Maybe a special class MimeHeader that will just have the constants.

Yes, I think is a good solution.

from flowcrypt-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.