Get your CodeRanch badge!*
The moose likes Servlets and the fly likes java mail attachments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "java mail attachments" Watch "java mail attachments" New topic
Author

java mail attachments

Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
I am using java mail package to send attachments in my email. I have few questions regarding this.
1) When i do attach the file on to my email, it works fine on my windows machine. It doesn't work on unix machine, it throws FileNotFoundException, saying c:\test.doc not found.
Do i have to store this file temporarily on the server or how does this email attachment work on unix system.
2) Also, is there any limit on the size of the attachment file?
3) Also, if i attach multiple files, does the size limit to combined attached files or individual attached files?
Appreciate your input,
Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60056
    
  65

I imagine that this will get moved to a more appropriate forum before long, but to answre your first question:
c:\test.doc is not a valid unix file path.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 264
U should write as what ever operating system like this .where Mail_Home
java.lang.String Mail_Home=(String)session.getValue("Mail_Home");
U write one prop file like this
Mail_Home=c:/Imail.

then u can apply this one
******
java.io.File f=new java.io.File(Mail_Home+"/userdir");
****************
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
Thanks for the reply. I agree with having emial_home property. Does that mean the attached file must exist on the server side to solve this path issue.
Our server is running on sun solaris m/c and client(browser) on PC. When i attach a file in my email, do i need to store this attached file temporarily on the server to send the email?
Thanks.
Please let me know,
Appreciate your help.
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Mandy,
i dont get u. which server r u talking about? Email Server to which ur JavaMail program sends emails to be sent out?
where is your Java Mail program? I guess its on the client side (downloaded thru applet or u know something like that)...if its not on the client side then how u r invoking it?
sorry but i am kinda lost about what exactly u r having and how u r accessing??? can u please clarify more on this?
thanks
maulin.
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
Hi,
Sorry for the confusion. What i meant by server was my WebServer. I am not talking about the email server here. I have Weblogic server running on sun m/c, which is running my email program and a servlet(servlet invokes my email program). From the browser when i invoke this servlet, it will generate a form to specify subject, body part, from address, to address & file attachment capability.
When i attach my local file(file that exists on my PC) to this form and when i click on Send Email button, it throws a FileNotFoundException.
So, my question is should i store this attached file temporarily on my weblogic server until the email is sent? After sending i can delete this file.
Any further help on this would be greatly appreciated.
Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60056
    
  65

Mandy, remember that your servlet and/or JSP is running on the web server and then sending the generated response to the client browser via the HTTP connection created for the response. It certainly does not have access to the filesystem of the client (imagine the security ramifications of that were that possible).
If you want your server to have access to the file, you will either need to store it on the server, or somehow make the filesystem of the system where you will be storing the file available via a mechanism other than HTTP.
hth,
bear
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
Thanks Bear Bibeault!
So, i am planning to temporarily store the file under tmp directory on the server(webserver) until the email attachment is sent. After the email attachment has been sent, i will delete this file from tmp directory from my webserver.
Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java mail attachments
 
Similar Threads
unable to view email attachments!!!!
Sending file attachement from the client-side
Reading .msg files in an email as attachment
How to send java mail with big file attached
Size of Attachment: JavaMail