-1

I"m trying to edit email files that are saved on a network drive. They are in the msg file format. I'm able to read them into the a string value using Simple Java Mail, but i need to add some text to the body of the email and when i do, it removes the body of the email. It doesn't seem to matter where i put the text.

I've tried add the text at various places in the string, but no location seems to work.

File f = new File("EMAIL FILE");
// EmailConverter is from Simple Java Mail
String eml = EmailConverter.outlookMsgToEML(f);

// Various attempts to add the text at multiple locations

BufferedWriter out = new BufferedWriter(new FileWriter(outputLocation));
out.write(eml);
out.close();

What i'm looking for is that the text gets added to the start of the body of the email.

theNewb
  • 75
  • 1
  • 5

2 Answers2

0

String is immutable, in the sense, that you can't change its value unless you're reassigning it. Sounds, like you want to append some additional information to your eml content

Have you tried StringBuilder ?

Arvind
  • 58
  • 5
  • I can update the string that isn't the issue. The issue is that when i do add the text and save it the body of the email disappears. – theNewb Aug 21 '19 at 21:29
  • Well, I'm not sure how you're executing the edit. Would need more info on that. Are you parsing the eml file ? If yes, how are you doing it ? Have you tried using javax.mail API ? [link](https://stackoverflow.com/questions/157195/create-a-eml-email-file-in-java) – Arvind Aug 22 '19 at 17:45
-1

I actually was able to edit the body of the email. Looks like there are multiple versions of the email body in the string generated by the EmailConverter.outlookMsgToEML(f); command.

Once i updated all instances of the text that i wanted to change it worked as I was hoping.

theNewb
  • 75
  • 1
  • 5