Java - How to strip an email signature while parsing the email? - java

I have a program which checks the unread email from an inbox, parses and sends the content of the email to a record. If there are any images in the email, those images will be sent as attachments to the record. Now if any email is having an image in the signature part of the email, that image is also being sent as an attachment.
Is there a way that I can check for the images in the signature part of the email and ignore them? or Is there a way around where I can skip the entire signature content from getting parsed?
Emails sent from outlook are high priority here. So Is there a particular standard in outlook of how the emails can be parsed for signatures?.

Related

Is it possible to get details of the email for which user had replied?

I am using amazon SES to send notification emails in my project. When a user replies back to this email I want to trigger some actions (like a ticket creation or update). Is it possible to know the contents or headers of the email for which user is replying ?
If the replying user's email system supports it (most do), you should receive an In-Reply-To: Header containing the message-id of the email you sent. If you kept that message (along with the message id) you can use this to retrieve original email.
Sometimes the Refereces: Header might be useful as well

JAVA mail api: Why you need Multipart in order to send email with attachment?

I want to send an email which contains only an attached file, no text or anything else.
Why should i represent this as one bodypart of a multipart email?
Why i can't just write
message.setFileName(filepath);
When in the other hand this works
message.setText("blablabla");
Because this is the MIME standards, all email messages should follow the MIME RFC in order for email clients to properly display the email. An attached image is binary data, while a message body is always ASCII, a user cannot open an email with binary in the body displayd, that would be useless. The binary code of the image is translated to BASE64 so the binary can be transfered in sort of ASCII characters and this has to sit in an email MIME boundary. The email software knows how to find these boundaries and will either show the image to the user as an attachment, or displayed the right way in the body, depending on how you setup your MIME boundaries. Multipart means the email has multiple boundaries, where the ASCII email body is one of them, no matter if that one is blanc or not.

Get just the url of attachment javamail api?

I want to save the url of attachment into mysql database in order to download it from mobile client (iphone) when user demand downloading attachment.
String disposition = part.getDisposition();
if (disposition != null && (disposition.equalsIgnoreCase("ATTACHMENT")))
// mail have attachment
I'm using this code to get the part of the message which is an attachment.
But i can't get it's url.
Any idea?
You should not try a url for attachment approach. For your attachments to have a url, you need a server that will hold all attachments, and you will to embed the url to an attachment in theemail, before it is sent out.. which can only be possible if te email is sent from your sysem.
You should instead look at it like asking a user before loading the attachment part of the message. If the user says yes, load the whole email, including the attachment.

Sending HTML formatted email in Android

I have successfully created an Android app that calculates prices and then is able to transfer that data in a preformatted fashion to an email program of the users choice. Depending upon the data the user creates in the app, a string containing the HTML is read into an intent. The code I have for this is:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(emailText));
QuoteDroid.this.startActivity(emailIntent);
This is all fine and the email is mostly formated correct when I choose the Gmail app, and generally sends mostly correct. The issue I have with this is that I must send it from a non-gmail account for business purposes. When I choose the generic email app on the phone it does not process the HTML properly and when I send the email it is formated in plain text.
I've read through countless articles and forum posts, but to no avail. How do I process the string, containing the HTML, in such a way that the email -after being sent with the built in email app- is viewed properly formated by the receiver?
It's up to the individual mail app to properly handle the String that it receives as the EXTRA_TEXT. A well-behaved mail app will see the mimetype and handle the EXTRA_TEXT appropriately, but not all mail apps do.

How can I send two emails via javamail such that outlook will put them in the same conversation?

At some point, I've sent an email and it is processed and received by an exchange server and then viewed by an outlook client. At a later point, I send another email where it is a reply/related to the 1st email. I want outlook to know that they are related and group them together when I group emails by conversation.
A couple of caveats:
I won't have access to the 1st email's message object to reply off of.
I will have the subject, messageID, and body of the first email when composing the 2nd email.
I've tried adding the "in-reply-to" and "references" header fields in the 2nd email, but outlook will not conversate them. Thunderbird and Gmail will thread them appropriately, though.
When grouping messages into a Conversation, Outlook will most likely not use the header fields but rather the subject line. It will ignore words like Fw: and Re:.
Try prepend a Re: to the first message subject and use this as second message subject.
Ref: http://lifehacker.com/157042/make-outlook-thread-conversations-like-gmail

Categories