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 5843925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:13:19+00:00 2026-05-22T12:13:19+00:00

I want to attach multiple files inside a calendar invite using java. Currently i

  • 0

I want to attach multiple files inside a calendar invite using java.
Currently i am able to create an invite with the html body text but i am not able to add attachments to that invite.

Does anyone knows how to attach files.

I am not sending the invite as attachment. It is going as normal accept/decline way.

Please post ASAP .
Thanks in advance

CODE AS FOLLOWS :

    MimetypesFileTypeMap mimetypes = (MimetypesFileTypeMap) MimetypesFileTypeMap.getDefaultFileTypeMap();
    mimetypes.addMimeTypes("text/calendar ics ICS");

    MailcapCommandMap mailcap = (MailcapCommandMap) MailcapCommandMap.getDefaultCommandMap();
    mailcap.addMailcap("text/calendar;; x-java-content-handler=com.sun.mail.handlers.text_plain");


    Properties props = new Properties();
    props.setProperty("mail.transport.protocol", "  ");
    props.setProperty("mail.host", mailServer);
    //props.setProperty("mail.user", "emailuser");
    //props.setProperty("mail.password", "");

    Session mailSession = Session.getDefaultInstance(props, null);


    MimeMessage message = new MimeMessage(mailSession);
    //message.addHeaderLine("text/calendar;method=REQUEST;charset=UTF-8");

  /*  String emailAddress = invite_email;
    String fullName = invite_name;*/

    String emailAddress = "XYZ@aBC.com";
    String fullName = "ABCD";
    message.setFrom(new InternetAddress(replyEmail, replyEmailName));
    javax.mail.Address address = new InternetAddress(emailAddress, fullName);

    message.addRecipient(MimeMessage.RecipientType.TO, address);
    message.setSubject("abc" + invite_sub);

    // Create a Multipart
    Multipart multipart = new MimeMultipart("alternative");

    //part 1, html text
    BodyPart messageBodyPart = buildHtmlTextPart(team_id);
    multipart.addBodyPart(messageBodyPart);


    // Add part two, the calendar
    BodyPart calendarPart = buildCalendarPartNew(emailAddress , fullName , invite_sub , invite_uuid ,start_date , finish_date , invite_seq , invite_status , invite_timezone );
    multipart.addBodyPart(calendarPart);

    // Add attachments to the body


    multipart =  addAttachment(multipart,Req_List);


    //update the requisition id list back to " " once the attachment process is over
    Req_List = " ";

    // Put parts in message
    System.out.println("setting the content of message");
    message.setContent(multipart);



    // send message
    try {
        Transport transport = mailSession.getTransport();
        transport.connect();
        transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
        transport.close();
    }
    catch (Exception ex) {
        System.out.println(ex.toString());
        throw ex;
    }

THE FUNCTION FOR ATTACHMENT MAINLY CONTAINS :

FileDataSource fds1 = new FileDataSource(sharepath_name);
        attachment.setDataHandler(new DataHandler(fds1));
attachment.setFileName(fds1.getName());
        attachment.setHeader("MIME-Version", "1.0");
        attachment.setHeader("Content-Type", " "+mime_type+ "; name=\"" + sharepath_name + "\"");
        attachment.setHeader("Content-Disposition", "attachment;          filename=\"" + sharepath_name + "\"");
        attachment.setHeader("Content-Transfer-Encoding", "base64");
        multipart.addBodyPart(attachment);
return multipart;

there is no error as such , the invite is getting generated with the text , but the main problem is i want attachments inside the invite, i am not able to attach files inside the invite, i don’t know how to attach files inside invite ?
Also the attachments i need to provide multiple attachments inside the invite.

Thanks in advance

  • 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-22T12:13:20+00:00Added an answer on May 22, 2026 at 12:13 pm

    Have you tried without setting the attachment headers manually? They should be set by MimeMessage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send a HTML file as message body and want to attach
PROBLEM I want to be able to attach one/multiple attachment(s) as the document is
i have a Button on a HTML page . i want to attach file
In my application I want to attach multiple photos to an email in code,
I want to attach an xslt stylesheet to an XML document that I build
I want to attach a 'click' event handler to the first child of an
So, what I want is basically to attach a javascript handler to a form,
want to know why String behaves like value type while using ==. String s1
Want to be able to provide a search interface for a collection of objects
The following Java code is used to attach a file to an email. I

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.