I am developing a web application using Oracle ADF and jdeveloper11.1.2.4. In that I have a form to send a mail with required input fields. Example toAddress, ccAddress and attachemnt Location(input text field). I am sending mails using java mail api. I got this information from the post
Mail using java
My problems is with attachment file. I am able to send an email successfully with attachment if I gave a location of the file that is on server(on which my application has deployed).
Beacause my application is web application user can access through internet. If am trying to add a location of the file that is in local system(Other than server) then file is not getting attached and mail is not getting send.
I am unable to attach a file from other than server.
Please help me. How do I achieve this. User should be able to attache a file from his/her system(local system).
First upload your file to server directory
see- http://www.awasthiashish.com/2014/08/uploading-and-downloading-files-from.html
Then provide a path when sending mail
see-http://www.awasthiashish.com/2013/04/gmail-integration-with-oracle-adf-using.html
First you will have to upload the file to the server and then attach that file in your email as JavaMail will need an absolute path on your current server.
PS: If you are sending emails using java I would highly recommend looking at Apache Commons email library https://commons.apache.org/proper/commons-email/userguide.html
It will make your life a lot easier.
Related
I need the solution for the below problem in Java -
On arrival of new mail in ms outlook for a particular email id, there should be a web service get executed automatically.
is it possible? please help!
You can do that using java mail. You will need to find the configuration details but a standard code snippet for this would be something like below. I copied the code snipped from here. Thos official javamail link has a pretty decent set of examples (ie. how to read attachments).
For storing the email as a file to a folder, you can apache FileUtils. Write the email to a file and copy it to a folder that you desire.
There is one more interesting resource
I have been using Java mail API to send mails generated through the Java program. What I want to do now is to send a mail through Thunderbird mail client so that the mail get saved to the sent items folder of the user and the user can resend a mail if it has failed.
I also would like to know if it's possible to get a delivery report in the Java mail API.
Edit
I found out that our mail server is POP3 and it doesn't store mail. So is it a good idea to send another mail to the sender as well and define a rule that categorize those messages?
even if you send it with the java mail api (well gmail at least), you will still be able to see in the sent folder using thunderbird. as a matter of fact, 5 minutes ago, I saw this using a website that I build. I am sending emails using Java API, and when I check the send folder I can see them.
The InBox / Outbox in Thunderbird are normally mapped ti your IMAP-Account. The IMAP-Account is set on a mail server. All your mails and folders are stored on that mail server. the client (Thunderbird) only shows the contant from the server. By remote calls (IMAP-protocol) you can create/delete/edit/move folders and mails on the server. Sending a mail is not part of IMAP. Here you use the SMTP-Protocol. When you configure a mailaccount in Thunderbird you must configure IMAP & SMTP. When you send a mail Thunderbird does the following steps:
- Send Mail by SMTP-Protocol
- Create Mail in Outbox by IMAP-Protocol
SMTP & IMAP are totally different. But if you want to send a mail and see this mail in your outbox you must use both. You can program the same workflow with the java mail api.
If I get your question right, you are looking for a way to trigger mail sending via Mozilla Thunderbird from a Java program (an external program / software running on the same local machine).
You can achieve that via different methods:
calling the Thunderbird binary with command-line arguments
via SimpleMAPI, which Thunderbird supports
via XPCOM, also built into Thunderbird
What you won't be able to achieve easily is getting feedback from Thunderbird about the outcome of triggering / prompting the user to send a mail. But you could achieve that by using more difficult ways of integrating Thunderbird with your external software:
read and parse the actual MBOX inbox / mail sent / profile files in a user's profile. "using the X-Mozilla-Status headers (you could) figure out if a message is a new message (etc). A mbox file is essentially just a flat text file that has a seperator between the messages" (parentheses by me, source)
Write a bridging WebExtension Thunderbird Add-On that integrates in some way with your software. An extension has, via Thunderbird's WebExtensions API, essentially a hook for every feature Thunderbird has and your code Add-On could expose these internals in some way to your software.
AFAIK and sadly Thunderbird, as it ships, exposes no API or similar interface out of the box.
Perhaps this kind of question comes under not to ask category but for the sake of application I have to ask.So pardon me.
At the time of Log in,I found that(suppose)If I am unable to remember my password,then I have to put my email-id then an auto generated reply come from that's hosted site with
a new link for generating another new password or
simply sending password(that means password isn't encrypted,I guess) in reply.
watching the source code it's hard to predict,but I want to know(if they are using jsp) then which protocol is used for this auto generated mail what are the other things to remember to achive this, while I'm also making an application for auto generated mail.
I have done this using javax.mail api in java
google for sending mail using java...
define content of mail in template or resource file and send mail whenever user clicks on forgot password link.
It is using SMTP protocol only.
I want to copy/move an Excel from local machine/given path to Server location.
The server location , we manually uploads the Excel file but i want to do it autmatically by using Java files.Can i do it , if so please give me a suggestion on it.
How do we skip those uploading mechanism which we do manually.
thanks in advance
VSRK
If you upload it via a web form, you can use Apache HttpClient to programmatically create the request sent to the server and upload the file. You will need to handle by yourself any authentication needed before the upload, store any cookies the server sends you, and do any post-authentication navigation the web page requires. You will also need to recreate the upload request exactly as the web browser sends it, parameters and all.
Is it possible to send the file as a link instead of attaching the file in the email. I am sending an email using Java . Now, i have a requirement thatI don't want to send the file as an attachement instead I need to send it as a link.
Link will something be like abc.com\report\excel\"fileName", in which abc.com is the host/ machine name, and rest is the path location.
Thanks.
Mail format does't allow meta-attachments (i.e. by reference, not by instance).
Your only option is sending HTML email with HTML link to the file (and of course it should be accessible via internet).