• Post Reply Bookmark Topic Watch Topic
  • New Topic

issue when sending email with url openConnection

 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to automate a process and send myself email about how it went, and here's the meat of my code:

This seems identical to code I've successfully used before and seems to match up with tutorials I find online, but for some reason, the stuff in the body is getting stuck on the subject line, which is unacceptable since there's so much information. I've tried different variations, like the java.io.PrintWriter's print and println statements, putting "Body: " in front of the body text (when I do that, nothing appears in the body of the email), etc. The body text is a StringBuffer and then a String (I've tried printing both) that I read in from a simple text file.
In my To, From, and Subject fields, any words separated by spaces that I put after each colon get strung together with periods, so the To becomes Jim.Jones, the Subject becomes Process.completed, etc. Do I need to escape those spaces somehow or something like that to get it not to do this?
FYI, I've more or less followed examples like this one:
http://www.jguru.com/faq/view.jsp?EID=126822
Thanks for any help...
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fascinating. I've never seen this before. Cool.
The only significant difference I see between your code and the example you cite is that the example doesn't have a "To" line, and starts with the "From" line. Perhaps that's important.
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solution: Need a println between the Subject and body print statements. I found that out from this example:
http://examples.oreilly.com/jenut/SendMail.java

Yeah, I used stuff like this 6 months ago and loved it for lightweight email logging of a few tasks here and there...don't have to install JavaMail for this.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great. So the first example you cited is actually wrong?
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah. Fun stuff.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!