Forums Register Login

Javamail: Problem sending attachments

+Pie Number of slices to send: Send
have the following code for sending emails


Although the email content is absolutely fine, the attachement is not gettig attached. The email comes without an attachment. Can someone please let me know how to attach a file to this email

+Pie Number of slices to send: Send
I updated my code a bit.

If I do the following, I get only the attachment without the HTML body (html body part is commented)


the following gives me HTML body wihtout attachment



I need both. HTML body as well as an attachment.

Can someone please let me know how to solve this problem.

Thank you
+Pie Number of slices to send: Send
In your first example, you add all attachments, but then you overwrite them with the body.

You must use a MimeMultiPart, and create one body part for the HTML and one for each attachment. The file body part will work just as the one you have now; the HTML body part will be similar to how you set the HTML contents for your message.
+Pie Number of slices to send: Send
A similar problem, I have my body part working, if I comment the code to the the filename, attachment. I have created MultiMimePart for body and for attachment but still get the error. Any suggestions for this please

+Pie Number of slices to send: Send
got the answer to my question, was setting the filename incorrectly, Its amazing how much you could learn by looking at the code of others...

truely amazing !

thanks !
Wink, wink, nudge, nudge, say no more, it's a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 5388 times.
Similar Threads
Attaching files using Java Mail API
Java mail problem
Image as part of HTML email
Problem in Java Mail using Servlet
Forwarding a mail in message/rfc822 Format
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:21:21.