Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

javamail and attachments

  • 01-02-2005 1:04pm
    #1
    Closed Accounts Posts: 658 ✭✭✭


    Hi

    Im having a little problem re: Javamail and sending attachments. I know how to send an attachment when the source of the data is a file on the local filesystem, but how do I go about making an attachment if I want the file to be dynacmically created in memory instead and send to the use then ?

    I have a method to create the file in temporary memory using a ByteArrayOutputStream(), so can anyone help me with how to attach this to the email ? I have looked on the net and the tutorials only seem to deal with handling attachments from files.

    I know of FileDataSource and URLDataSource, but they arent much help.

    Thanks in advance :)


Comments

  • Registered Users, Registered Users 2 Posts: 2,426 ✭✭✭ressem


    Nope you create/get a different datasource.

    Take your usual "create mail" example

    http://www.jguru.com/faq/view.jsp?EID=30251

    but instead of
    DataSource source = new FileDataSource(fileAttachment);

    use
    DataSource source = new ByteArrayDataSource(byte[] data, String type);

    as provided in your javamail/demo folder under ByteArrayDataSource.java, or by a few other vendors.
    [Added]
    like org.apache.commons.mail.ByteArrayDataSource
    at http://jakarta.apache.org/commons/


  • Closed Accounts Posts: 658 ✭✭✭pontovic


    thank you

    much obliged


Advertisement