Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When replying to an email with HTML, the result body is empty #137

Closed
Diegofr104 opened this issue Apr 21, 2018 · 10 comments
Closed

When replying to an email with HTML, the result body is empty #137

Diegofr104 opened this issue Apr 21, 2018 · 10 comments
Assignees
Milestone

Comments

@Diegofr104
Copy link

Diegofr104 commented Apr 21, 2018

Hi, I was trying to make a reply to a email but it's sending with empty content, I tried using forward and is working fine.

Other thing when I set a flag for search answered not showing any answered messages (other answered messages answered in gmail UI are showing).

I'm declaring the mail same as says in page. I tried using plaintext(message) and same result.

Email sendMail = EmailBuilder.replyingTo(emailR)
			.from("Estancia XXI", emailE.getEmail())
			.prependText(message)
			.buildEmail();

sin titulo

@bbottema
Copy link
Owner

Ok, so if I read you correctly, you are using replyingTo() to send a reply, but in Gmail you see and empty body for the reply?

Then when you search for answered (how do you do this?) the reply is not showing up.

Correct?

@bbottema
Copy link
Owner

bbottema commented Jun 1, 2018

@Diegofr104, can you verify my summary?

@Diegofr104
Copy link
Author

Diegofr104 commented Jun 2, 2018

first, you are correct i saw an empty body. when i try to saw what was sended.

for the second thing.
I get all the not answered mails in my app using java mail, then i select one from the list and reply the mail i want.
After that i move to other panel in the app that i can get the answered ones and shows empty.

If you need a little more code i can paste here so you can see better.

@bbottema
Copy link
Owner

bbottema commented Jun 2, 2018

That would be very helpful, @Diegofr104. Especially "I get all the not answered mails in my app using java mail" I would like to understand better.

@bbottema
Copy link
Owner

bbottema commented Jun 3, 2018

@lacivert, did you have any issues like this?

@bbottema
Copy link
Owner

bbottema commented Jun 3, 2018

@Diegofr104

Actually, I have an idea of what is going on. Replying to a message always sets HTML content as well. But you use .prependText(), which is ignored by modern clients if HTML is present.

Try this instead:

Email sendMail = EmailBuilder.replyingTo(emailR)
			.from("Estancia XXI", emailE.getEmail())
			.prependText(message) 
			.prependTextHTML(message) // < add this line
			.buildEmail();

Or remove the HTML content completely, leaving only the text:

Email sendMail = EmailBuilder.replyingTo(emailR)
			.from("Estancia XXI", emailE.getEmail())
			.prependText(message) 
			.clearTextHTML(message) // < add this line
			.buildEmail();

I've updated the Javadoc for replyingToEmail as well.

@Diegofr104
Copy link
Author

Im having 0 time right now to test your solution,i will do tomorrow if i have some little space between work.
Thx.

@bbottema
Copy link
Owner

bbottema commented Jul 1, 2018

Did you verify either of these suggestions solve your issue?

@bbottema bbottema removed the bug label Jul 1, 2018
@bbottema bbottema added this to In progress in Version 6.0.0 Aug 1, 2018
@bbottema bbottema moved this from In progress to On Hold in Version 6.0.0 Aug 1, 2018
@garrettlr
Copy link

garrettlr commented Oct 3, 2018

@bbottema not OP but think i'm facing the same issue -

In my case I've got an email with only text/html + attachment content, no text/plain.

using the below, I get a reply that does not include the original email body.

Email email = EmailBuilder.replyingTo(original)
  .clearReplyTo()
  .withReplyTo("name", "email")
  .from("name","email")
  .prependTextHTML("<div dir=\"ltr\">Origianl message should be below</div>")
  .buildEmail();

If i forward this email, it works brilliantly, but fails on reply entirely.

Not sure, but i think the issue might be line 303 of email::emailBuilder:

.withHTMLText(format(htmlTemplate, defaultTo(repliedTo.getPlainText(), "")))

which i think should read:

.withHTMLText(format(htmlTemplate, defaultTo(repliedTo.getHTMLText(), "")))

EDIT: @bbottema I've made the change I described above, and that has solved the problem. I'll send you a PR.

@bbottema bbottema changed the title replyingTo sending empty content When replying to an email with HTML, the result body is empty Oct 3, 2018
@bbottema bbottema added this to the 5.0.5 milestone Oct 3, 2018
@bbottema bbottema self-assigned this Oct 3, 2018
@bbottema
Copy link
Owner

bbottema commented Oct 3, 2018

Fix released in 5.0.5, please confirm.

@bbottema bbottema closed this as completed Oct 3, 2018
Version 6.0.0 automation moved this from On Hold to Done Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Version 6.0.0
  
Done
Development

No branches or pull requests

3 participants