HI all, This is Ashok. Actually I got the requirement like on click of a button , then it should open a default mail client with automatically attached pdf in the local path which is generated dynamically. So , i tried a lot with 'mailto' and 'desktop' class but when I deploy it in server and tried to hit that url in another system, then mail client is opening in my system not their system and also not able to attach file with both 'mailto' and 'desktop' class. So, pls help me on this issue and can anyone help me in detail for how to do this 'Opening an default email client with attachments using java code in the respective systems on which they are clicking the email button?' . Pls do needful and help me so that it is very helpful and I will be very greatful for u.... Pls help me on this issue and suggest me the right solution and mail me on this if any one knows the solution and its very urgent. My mailid is 'ashokkumar1531@gmail.com'
Opening a mail client will open the mail client on the computer clicking the link. You can't click the link and have a mail client on another computer open, if that's what "mail client is opening in my system not their system" means. Javascript has VERY limited access to the local file system (deliberately - allowing it full access is a HUGE security hole), so you're going to have a problem accessing a local file for any purpose other than uploading it to the server. "Opening an default email client with attachments using java code" Really? Java doesn't do email, Javascript does. (The only thing they have in common is 4 letters in the name.) And how do you know that the user has the pdf file on his system? It would be much easier to upload the file to the server, then email it from the server. Emailing an attachment in PHP is kind of trivial - most email classes do it. (If you mean that the pdf file is on the server, and you want the user's email program, on his computer, to send that file as an attachment, that's less than impossible. Just have the server send the email.)
Hi Rukbat, Thanks for ur reply and actually I have 3 options in my application 1- saveas pdf, 2- print, 3- Email. When we click on first option it will save all the data as pdf in the path in server, and this application is automatically generating an pdf when we click on 'print' button so i am storing that pdf in temp folder in the server so after that i need to get that pdf from temp and attach it to email client. And "mail client is opening in my system not their system" means that actually i developed one application using 'desktop' class for opening an email client and tried to run that in apache tomcat server but when i replaced the localhost:8080 with my system ip address then i hit that url in my colleague system then there it is not opening the mail client there, instead it is opening in my system even though if i hit the url in other system. So what i need is that ," I need to open an default mail client with automatically attached pdf which is already generated and stored in temp folder on server" and this should be done in the respective systems who ever are using. Pls do needful..or reply me if u need more clarification on this... Help or suggest me ... Regards, Ashok.
As I said, it will be MUCH easier to have the server send the pdf as an email attachment. You can try something like mailto:recipient@mailserver.com?subject=The PDF File&attachment="\myfolder\myfile.pdf" Code (markup): but that will only work if the user downloads the file to that directory. Since you have no control over where the file ends up on the user's computer, it's too easyfor the user to break it, by just not having his file download path set the way you want it set.
But attachment is not working with mailto because when I use above code it is only opening the mail client and no attachment is attached to that. Do u know why this is happening , help me on using above code
Because the attachment, if I read your post correctly, isn't on the user's computer, it's on your server. And Javascript (including opening and running the email client) is running on the user's computer. Mailto can not attach a file on your server. It's not that it's difficult to do that, it's that it's not possible. You have to send the file to the user, you have to make sure that he saves it where you expect it to be saved, then you have to attach that file (the one he downloaded). If he doesn't download it, or if he downloads it to a directory other than the one you expect it to be in, it just will not work. That's why I said that you should do the mailing in PHP - it runs on your server, and is able to attach a file that's on the server. Mailto can not run a file that's on the server, no matter how many times you ask.
Thanks a lot for ur useful suggestion and i will try to use this. It was greatful for helping me and it was very nice for ur quick reply. Thanks a lot