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).
Related
I am trying to write a Java program where I need to send an image to Gmail. I am sending the image as an embedded object.
<img src="data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAsCAYAAADmZKH2AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABISURBVFhH7c4hAQAgEAAxEhGGZN8YOkwhTsxvnT33V+VUOVVOlVPlVDlVTpVT5VQ5VU6VU+VUOVVOlVPlVDlVTpVT5dTHubkPuMrNUFKjQWUAAAAASUVORK5CYII=">
Other mail service providers are showing it fine, but Gmail specifically is removing it, so it is not visible in the message.
How can I make it visible in Gmail as well as the other mail service providers?
Place the image in a publicly accessible server and give the url for src attribute instead of dataUrl.
It is not possible in Gmail, outlook etc. They ignore base64 images.
For further information follow the link at below.
https://www.campaignmonitor.com/blog/email-marketing/2013/02/embedded-images-in-html-email/
There is an alternative way for doing this. Embed images in the email using the cid method. (Basically including the image as an attachment, and then embedding it).
https://www.campaignmonitor.com/blog/how-to/2008/08/embedding-images-revisited/
I can download attachments from an email account using JavaMail API. But is there any way to get the download links of the attachments of an email using Java?
For my purpose, I need to get the download links of the attachments and provide them to user. So that the user can download those attachments directly from email server. I will highly appreciate any other kind of suggestion.
The attachments in the email are the integral part of an email. It is just another MIME part in the email. You won't be able to get directly the attachment as a web resource.
To do so you can parse the email and store the attachment on the filestore and then provide it as a web resource.
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.
I've been searching for the best way to send an e-mail with an attachment by my java application. I want to use this as an users bug report with logger files. The recipient should be my own e-mail address. I'd prefer the use of an e-mail client.
I tried the following:
Send an e-mail with user authentification like this. I don't want to use this, because the user would need to reveal his e-mail account and password. Furthermore, I'd have to set the properties for every e-mail adress, which is impossible.
Send an e-mail directly to my own e-mail address like this in Listing 16.16 (didnt found an english example). The problem is every e-mail server is using POP authentification nowadays, that means the recipient e-mail server won't accept my e-mail.
Using the mailto URL syntax like this. Doesn't work aswell, because the attachment function isn't working properly in every e-mail client. Best solution so far is to brief the user to add the attachment by himself, after I would put it to his desktop. Or upload the data and add a link to the e-mail body.
The last way I've found is this one. As you could assume this won't work either, because the localhost needs to be connected to the internet and capable enough to send an e-mail.
Hopefully I explained my problem well enough. Is there a different way to send bug reports?
The generally accepted way to get around the problems you describe is to keep all the email logic server side, and then have your application call a web service with the appropriate parameters. It's pretty easy to knock a PHP script / servlet up that will do the job and then send the results on via email, put them in a mysql database or so on.
However, if you can't / don't want to / won't keep this server side, I'd recommend using JavaMail to create a MimeMessage, then using writeTo() to write this to an EML file.
You can then do the usual:
Desktop.getDesktop().open(emlFile);
...which will open the EML file with the default application for handing those files, which is almost always the mail client. Still not foolproof, but if you're determined on sending the email from the client directly I think that's as good as you'll get.
I am developing a Mail Client in Java (JSP and Struts). I have successfully fetched Message header information and stored in my local Database (including Message ID and subject).
When the user views the mails, I fetch the message headers from my database and display them to user. Now when the user click a particular Email, I want to fetch the mail body and file attachments from the Gmail server, directly. I don't want to serially travel through all the mails on the Gmail Server.
I have done this earlier in PHP, where if I pass the message id and I can retrieve the details of that particular mail. Is there any similar functionality in Java Mail API? If not, then can anyone suggest me a solution to this?
You can use Folder#getMessage(int) for this.
Note that the zip file with the JavaMail API which you can download from their side includes a lot of examples in /demo folder, under each a basic(!) Servlet which shows a simple mailbox with this functionality. You may want to build, refactor and expand further based on the simple example.