Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MessagingException: IOException while sending message  RSS feed

 
usha mocherla
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I am trying to send the attachment but i am getting this exception.
Below is the detail exception:
Exception thrown in sendSending failed;
nested exception is:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException: web1.xml (No such file or directory)

I am doing this application in the struts framework.When i am trying to run the logic in the simple java program,i have to give the complete path of the file and then it is taking the file,otherwise not.
In struts from the jsp page i am getting only filename and not the complete path.How to get the complete the complete path of the file from the jsp page.
To take the file name from the system i am using html:file tag.
Can anybody help me.
Thanks and regards
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your files are packaged in a WAR, you'll need to use the ClassLoader methods to get an InputStream for the file. Don't use java.io.File! Do something like this:
 
Kunaal A Trehan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In case u have set of files which u want to send as attachment.
U package them in some directory in the war file.
Then using servletContext() u can access that resource.
eg.
Inside WEB-INF/fileDir u have a file called abc.txt

Using servlectContext().getResourceAsStream("/WEB-INF/FileDir/abc.txt")
U can do the attachment

Kunal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!