November 29th, 2012, 05:42 PM
JavaMail / InputStream
I've got the following code working almost perfectly apart from the InputStream seems to be losing the first line of the text file?
Note: I have removed required try/catch blocks for readability.
The result is an email (it sends successfully) with a text file, called the correct thing (strLink), but it's missing the first line
// Create a multipart message.
// Assume the body text is already added
Multipart oMultiPart = new MimeMultipart();
String strLink = "http://mysite.com/file.txt";
URL oURL = new URL(strLink);
// oURL.openStream() returns the InputStream
MimeBodyPart oAttachmentPart = new MimeBodyPart(oURL.openStream());
Text file is:
and the attachment is broken (no text shown).
Whereas if I use this file, it is perfect
(an intentionally blank line)
November 29th, 2012, 09:16 PM
I don't see any obvious issues with your code, and I'm not sure what MimeBodyPart does/is, but I see in the constructor doc Available Here it notes that
Are you sure that you have satisfied these conditions?
<Tetrad> the program I just wrote 1) compiled the first time without any errors and 2) worked like it was supposed to
<Tetrad> I don't know whether to be proud or scared to death
Originally Posted by DaWei_M