Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6213059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:37:40+00:00 2026-05-24T06:37:40+00:00

I have an application where i have to generate a file either it could

  • 0

I have an application where i have to generate a file either it could be an txt file. All i want is to send some reports over mail either by mail or attachment in mail.

please help me how to do this?

The data format is something like a tabular format.

//create a multi part
            Multipart mp = new Multipart();

            //data for the content of the file
            String fileData = "<html>just a simple test</html>";
            String messageData = "Mail Attachment Demo";

            //create the file
            SupportedAttachmentPart sap = new SupportedAttachmentPart(mp,"text/html","file.html",fileData.getBytes());

            TextBodyPart tbp = new TextBodyPart(mp,messageData);

            //add the file to the multipart
            mp.addBodyPart(tbp);
            mp.addBodyPart(sap);

            //create a message in the sent items folder
            Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.SENT);

            Message message = new Message(folders[0]);

            //add recipients to the message and send
            try {
                 Address toAdd = new Address("nilanchala_p@spanservices.com","Nilanchala");
                 Address toAdds[] = new Address[1];
                 toAdds[0] = toAdd;
                 message.addRecipients(Message.RecipientType.TO,toAdds);
                 message.setContent(mp);

                 Transport.send(message);
            } catch (Exception e) {
                 Dialog.inform(e.toString());
            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:37:41+00:00Added an answer on May 24, 2026 at 6:37 am

    The best way is to send the table using plain text with html formatting

    <table border="1">
        <tr>
            <td>row 1, cell 1</td>
            <td>row 1, cell 2</td>
        </tr>
        <tr>
            <td>row 2, cell 1</td>
            <td>row 2, cell 2</td>
            </tr>
    </table> 
    

    No need for a file… Just format and send

    Ok try this:

    //create a multi part
                Multipart mp = new Multipart();
    
                //data for the content of the file
                String fileData = "<html>just a simple test</html>";
    
                //create the file
                TextBodyPart tbp = new TextBodyPart(mp,fileData );
    
                //add the file to the multipart
                mp.addBodyPart(tbp);
    
                //create a message in the sent items folder
                Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.SENT);
    
                Message message = new Message(folders[0]);
    
                //add recipients to the message and send
                try {
                     Address toAdd = new Address("nilanchala_p@spanservices.com","Nilanchala");
                     Address toAdds[] = new Address[1];
                     toAdds[0] = toAdd;
                     message.addRecipients(Message.RecipientType.TO,toAdds);
                     message.setContent(mp);
    
                     Transport.send(message);
                } catch (Exception e) {
                     Dialog.inform(e.toString());
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET console application that needs to generate some HTML files. I
I have integrated the below code in my application to generate a 'pdf' file
I have an application to generate dynamic reports using dynamic SQLs. The results of
I'm working at a small office,I have an application,it's generate a big text file
I have an application that uses window.open() to generate dynamic popups. Unfortunately, I've had
I have a PHP application and a need to generate a PDF with the
I have a flex application that needs the ability to generate and execute JavaScript.
I have a Maven 2 RESTful application using Jersey/JAXB. I generate the JAXB beans
Background: we have an application that generates reports from HTML (that may or may
We have JSF web application that generates XLS file and gives user link to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.