Need Help on Sending Multiple Attachments

Hi to all,
I hope some one will help me.. Im stuck with this one. I can only send one attachment.
Is there someone who know how to send an mail with 2 or more attachments?
My code is below, I followed this code from the toturial:
Hope for a kind reply. :-)
Thankz..MimeMessage myMessage = new MimeMessage(s);           
            InternetAddress fromRec = new InternetAddress(strFrom);
            myMessage.setFrom(fromRec);                     
            Address[] toAddress = InternetAddress.parse(strTo);
            myMessage.addRecipients(Message.RecipientType.TO, toAddress );
            Address[] toCC = InternetAddress.parse(strCC);
            myMessage.addRecipients(Message.RecipientType.CC, toCC );
            Address[] toBCC = InternetAddress.parse(strBCC);
            myMessage.addRecipients(Message.RecipientType.BCC, toBCC );
            myMessage.setSubject( strSubject );               
            MimeBodyPart messageBodyPart =  new MimeBodyPart();           
            messageBodyPart.setContent(strMessage  + "<BR>" +URLResponse  , "text/html" );
            Multipart multipart = new MimeMultipart();
            multipart.addBodyPart(messageBodyPart);               
            /*Part two is attachment*/
            messageBodyPart = new MimeBodyPart();
            DataSource source = new FileDataSource( fileRepository);
            messageBodyPart.setDataHandler(new DataHandler(source));
            messageBodyPart.setFileName(fileName);
            multipart.addBodyPart(messageBodyPart);   
            /* Put parts in message*/
            myMessage.setContent(multipart);                           
            /* End */         
            Transport.send(myMessage);           

Your code is only adding one attachment. Just repeat the code
that adds an attachment to add more than one.

Similar Messages

  • Need help in displaying multiple attachments in a OAF Page

    Hi,
    I need to display attachemts of requisition line in a OAF Page(Notification Detials Page)and the attachments can be more than one.My custom VO returns it as a single string like url1, url2.. etc.
    I need to show them as seperate links.
    I tried using the Item Style as LINK.But it is not working.It is prefixing the server url before the View Attribute and creating a single link.
    Any help in this regard will be appreciated.Thanks in advance.
    Srini

    Hi skeerthi,
    If you are using the core attachments table (FND_ATTACHED_DOCUMENTS and the like), you can have a look on the Developer's Guide on chapter 4: Implementing Specific UI Features, section "Attachments", there is a seeded region available for displaying multiple attachments.
    If you are not, then i'd recommend refactoring :D... Just kidding, it would be nice to use the core feature, but if the table is custom, and the links are stored separated by commas, you will have to write controller code to implement that. That can be done by:
    1) Creating an Application module method that uses StringTokenizer to tokenize the attribute String (use getViewObject().getCurrentRow().getAttribute() to get the comma-separated value) and return that to the controller
    2) In the controller, receive the StringTokenizer and for each token, use the api createWebBean() to create an OALinkBean and add it to a layout region using addIndexedChild() api.
    This way you will dinamically create a Link for each attachment. If your layout region is, for example, tableLayout, you can create a rowLayout for each token, then create a Link, add the link to the row layout and finally add it to the tableLayout. By doing so, you will create a table-style attachment region.
    Hope it Helps
    Thiago

  • Iam unable to send multiple attachments with a mail using JavaMail?

    Hai to all,
    Iam unable to send multiple attachments with a email,see
    iam have succeeded in sending one attachment with a email.
    when iam tring to add two or more attachments to a mail,
    it is giving a Exception like this:
    javax.mail.MessagingException: IOException while sending message;
    nested exception is:
    java.io.IOException: No content
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:577)
    at javax.mail.Transport.send0(Transport.java:151)
    at javax.mail.Transport.send(Transport.java:80)
    at AttachFilesModified.sendMail(AttachFilesModified.java:185)
    at AttachFilesModified.main(AttachFilesModified.java:43)
    this is my code snipnet:
    BodyPart messageBodyPart = new MimeBodyPart();
    Multipart multipart = new MimeMultipart();
    if(body != null)
    messageBodyPart.setText(body);
    multipart.addBodyPart(messageBodyPart);
    /*if(attachments != null)
    for(int i = 0; i < attachments.length; i++)
    String filename="D:\\nagaraju\\apachi\\axis-bin-1_3.zip";
         //String s[]=filename.split("\\");
         //System.out.println(s);     
              //String s1=s[1];
              //String filename1=s[s.length-1];
    messageBodyPart = new MimeBodyPart();
    DataSource source = new FileDataSource(filename);
         messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName(filename);
    multipart.addBodyPart(messageBodyPart);
         //second file attaching
         /*String filename1="C:\\nagadoc.txt";
         BodyPart messageBodyPart1=new MimeBodyPart();
         DataSource source1=new FileDataSource(filename1);
         messageBodyPart.setDataHandler(new DataHandler(source1));
         messageBodyPart.setFileName(filename1);
         multipart.addBodyPart(messageBodyPart1);
    mess.setContent(multipart);
    Address[] allRecips = mess.getAllRecipients();
    if(toStdOut)
    System.out.println("done.");
    //System.out.println("Sending message (\"" + mess.getSubject().substring(0,10) + "...\") to :");
    System.out.println("Sending message................");
    for(int i = 0; i < allRecips.length; i++)
    System.out.print(allRecips[i] + ";");
    System.out.println("...");
    Transport.send(mess);
    if(toStdOut)
    System.out.println("done.");
    return 0;
    What's wrng with that code snipnet?
    Nagaraju G.

    This works fine with me, try it or compare it if you want.
    public void sendEmail( String from, String to,
    String subject, String body) {
    fMailServerConfig.put("mail.smtp.host", " <<mail server>>");
    Session session = Session.getDefaultInstance( fMailServerConfig, null );
    MimeMessage message = new MimeMessage( session );
    try {
    message.setFrom(new InternetAddress(from));
    message.setRecipient(Message.RecipientType.TO,
    new InternetAddress(to));
    message.setSubject( subject);
    message.setText( body);
    //Adds Attechment:
    Multipart multipart = new MimeMultipart();
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setText("Here are my attachments");
    multipart.addBodyPart(messageBodyPart);
    messageBodyPart = new MimeBodyPart();
    //first attachment
    DataSource source = new FileDataSource("C:\\img1.jpg");
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName("C:\\Telnor1.jpg");
    multipart.addBodyPart(messageBodyPart);
    //Second attachment
    DataSource source2 = new FileDataSource("C:\\img2.jpg");
    messageBodyPart.setDataHandler(new DataHandler(source2));
    messageBodyPart.setFileName("C:\\Telnor2.jpg");
    multipart.addBodyPart(messageBodyPart);
    //etc...
    message.setContent(multipart);
    Transport.send( message );
    }catch (MessagingException e){
    System.err.println("Cant send mail. " + e);
    The error on your code might be:
    BodyPart messageBodyPart1=new MimeBodyPart();
    DataSource source1=new FileDataSource(filename1);
    messageBodyPart.setDataHandler(new DataHandler(source1));
    messageBodyPart.setFileName(filename1);
    multipart.addBodyPart(messageBodyPart1);
    You don't need to create a new BodyPart, and apart from that you'r seting values on "messageBodyPart" but adding "messageBodyPart1" to your multipart :P
    Well see u and have a good one!
    p.s. i know it's a little late from the day you posted, but at least it might help somebody else :D .

  • How do I send multiple attachments in word format when the document is created in pages

    How do I send multiple attachments in word format on one em. The documents are in pages/numbers and if I use 'share' they each go into a separate  e mail

    Your welcome.
    New problem. Just purchased Docs Go Pro for iPad  word processor and there are buttons missing. Then when I go back to the App Store I clicked on app support and up comes server/webpage gone (basically). I Binged and there is not a direct site for support. How or who can be a help?

  • How can we send multiple attachments in a mail from iPad 2

    Hi,
    I am using a ipad2. I want to know how we can send multiple attachments through mail from iPad. I did not find any option of doing this. Is there a way to do this.
    Regards,
    Satyabrat

    You can't do it natively on the iPad (unless you just want to send up to 5 photos from the Photos app). I use the GoodReader app which supports quite a few document/file types (e.g. PDF, Excel, Word, pictures), and from that I can select multiple files (including different types) and attach them to the same email.

  • Need help in creating multiple signature forms?

    need help in creating multiple signature forms that can be digitally signed in adobe reader

    Automator gets a bit unweildy when trying to vary things outside of what the actions provide.  Since you are already using an AppeScript in your workflow, might as well do the whole thing:
    set baseFolder to (path to desktop) -- the location to create the folder
    display dialog "Please provide a new folder name:" default answer "test"
    set folderName to text returned of the result
    repeat -- keep repeating until a number is returned
      display dialog "How many subfolders?" default answer "5"
      set theNumber to text returned of the result
        try -- test the result
          set theNumber to theNumber as integer
          exit repeat -- success
        end try
    end repeat
    tell application "Finder"
      try -- make new folder
        set newFolder to (make new folder at baseFolder with properties {name:folderName})
      on error number -48 -- skip errors if the folder is already there
        set newFolder to ((baseFolder as text) & folderName) as alias
      end try
      repeat with X from 1 to theNumber
        try -- make new subfolder
          make new folder at newFolder with properties {name:folderName & X}
        on error number -48 -- skip errors if the folder is already there
        end try
      end repeat
    end tell

  • Cannot send multiple attachments since 10.5.8 with IMAP

    Have had a consistent issue that Mail 3.6 will not send multiple attachments, regardless of size, since the 10.5.8 update with a IMAP configuration. Under POP, as in Gmail, using Mail 3.6 with multiple attachments is no issue. Using IMAP through my Godaddy Hosted Domains, in some cases it actually is sending mail as verified through webmail "Sent" folder but does not show in Mail 3.6 "Sent" folder. Have verified this through sending from my IMAP Goddady hosted emails to my POP Gmail account accessed via Mail 3.6. Can also send successfully through webmail on Godaddy to any Pop or IMAP account.
    It seems something in the 10.5.8 update has altered Mail 3.6 to impact this functionality. As a business owner this functionality is crucial, may have to switch to Entourage.
    Any suggestions are appreciated.

    That crash is because of a bad result from an OS routine.
    Our best guesses involve corrupt application installs, or corrupt OS installs.

  • Need help Setting up Multiple Static Ip , 1 for each port of the fios router

    Need help Setting up multiple Static Ip on my fios router
    I have been trying to figure out how to set up multiple ip in my fios router.
    However I kind of managed how to set up multiple static ip However the way I want it is for each port of my router to have an external ip signed to it. ( like 4 different modem in 1 )
    Verizon gave me 5 static ip but they can not help me how to set it up.
    Have anyone here done more then one static ip on different ports? I assume that the process will be the after the second static ip.

    You want to set up Static Nat. You will not assign the IP to a port, but rather to a local machine. Figure out what machines you want your IP's to go to. Under the firewall section you will see static nat. Pick the machine you want and enter one of the IP's you were assigned.

  • Is it possible to send multiple attachments from pages?

    Hello,
    Is it possible to send multiple attachments from pages? Currently I'm facing problems with sending multiple documents from pages in an e-mail. I don't like to send a new e-mail everytime I want to share a document!

    You can only email one file at a time from Pages. There may workaround using other apps - sending the Pages files to another app that supports multiple attachments, so you could give that a try.
    read this discussion for one such workaround.
    https://discussions.apple.com/message/17331538#17331538

  • How to send multiple attachments with the mail in jsp

    hi.I wrote a code to send mail.but i need to send mail with multiple attachments.when i run this code iam able to send message but not files.i want to send files as attachments with the message.please help me.
    <%@ page import="javax.mail.*,javax.mail.internet.*,java.util.Date,java.io.*,java.net.InetAddress,java.sql.*,java.util.Properties,java.net.*,javax.sql.*,javax.activation.*,java.util.*,java.text.*" %>
    <%@ page import="java.io.*,java.sql.*,java.net.*,java.util.*,java.text.*" %>
    <%
         String Attachfiles1="";
         String Attachfiles2="";
    String Attachfiles3="";
    if("Send".equalsIgnoreCase("send"))
    try
    String subject="",from="",url = null,to="";
    String mailhost = "localhost";
    Properties props = System.getProperties();
    String msg_txt="";
    String strStatus="";
    String mailer = "MyMailerProgram";
    to=request.getParameter("to");
    from=request.getParameter("from");
    subject=request.getParameter("subject");
    msg_txt=request.getParameter("message");
    props.put("mail.smtp.host", mailhost);
    Session mailsession = Session.getDefaultInstance(props, null);
    Message message = new MimeMessage(mailsession);
    message.setFrom(new InternetAddress(from));
    message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
    message.setSubject(subject);
    message.setHeader("X-Mailer", mailer);
    message.setSentDate(new Date());
    message.setText(msg_txt);
    BodyPart messageBodyPart = new MimeBodyPart();
    BodyPart messageBodyPart2 = new MimeBodyPart();
    Multipart multipart = new MimeMultipart(); // to add many part to your messge
    messageBodyPart = new MimeBodyPart();
    javax.activation.DataSource source = new javax.activation.FileDataSource("path of the file");
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName("file_name");
    messageBodyPart2.setText("message"); // set the txt message
    multipart.addBodyPart(messageBodyPart);
    multipart.addBodyPart(messageBodyPart2);
    Transport.send(message);
    out.println("Message Sent");
    catch (Exception e)
    e.printStackTrace();
    if("Attachfiles".equalsIgnoreCase("attachfiles"))
    Attachfiles1=request.getParameter("fieldname1");
    Attachfiles2=request.getParameter("fieldname2");
    Attachfiles3=request.getParameter("fieldname3");
    %>
    <html>
    <body>
    <div class="frame">
    <form action="Composemail.jsp" method="post">
    <b>SelectPosition:</b> <select name="cars" >
    <option value="ABAP">ABAP
    <option value="saab">Saab
    <option value="fiat">Fiat
    <option value="audi">Audi
    </select><br><br>
    <table border="1" cellpadding="2" cellspacing="2">
    <tr><th>Name</th>
    <th>EmailId</th>
    <th>ContactNumber</th>
    <th>Position</th>
    </tr>
    <tr>
    <td>
    </td>
    </tr>
    </table><br>
    <b>SelectUser :</b><select name="cars">
    <option value="Administrator">Administrator
    <option value="saab">Saab
    <option value="fiat">Fiat
    <option value="audi">Audi
    </select>
    <br>
    <b>To :</b>�����������<input type="text" name="to" size="72"><br>
    <b>From :</b>�������<input type="text" name="from" size="72"><br>
    <b>Subject :</b>���<input type="text" name="subject" size="72"><br>
    <%=Attachfiles1%><br><%=Attachfiles2%><br><%=Attachfiles3%><br><br>
    <b>Message:</b><br>
    ������������<textarea rows="10" cols="50" name="message">
    </textarea> <br><br>
    <b>AttachedFile:</b>�<input type="file" name="fieldname1" value="filename" size="50"><br><br>
    <b>AttachedFile:</b>�<input type="file" name="fieldname2" value="filename" size="50"><br><br>
    <b>AttachedFile:</b>�<input type="file" name="fieldname3" value="filename" size="50"><br><br>
    ������������<input type="submit" name="attachfiles" value="Attachfiles">
    <center>
    <input type="submit" name="send" value="Send" >
    </center>
    </form>
    </div>
    </body>
    </html>

    Most likely you're not specifying the path of a file on the server machine.

  • How to send multiple attachments thru mail?

    I haven't been able to figure out how from the mail application send docs, worksheets etc as attachment. Also how to attach multiple docs in the mail. Looking for help on this.
    Sparashar

    You need to start in the app that contains the files that you want to send as attachments and use that app's functionality to select and attach files to an email, and not start in the Mail app e.g. the GoodReader app supports multiple document types (word and excel, read only, PDFs, text files, pictures) and allows you to select one or more of them and attach/switch with them to an email.
    In the Mail app itself on iOS 6 you can now press and hold the body of the email and select photos from the Photos app to attach to it.

  • How to send multiple attachments?

    Sorry if this seems like an obvious question but can it be done? Do I need an extra app or helper?
    Thanks in advance

    Ernie,
    I have had problems with sending some attachments to windows users.
    i cant tell exactly what is causing it.
    usually i am making .pages documents which i then export as PDFs.
    many times windows users email me back that they cant even see the attached PDFs (not not open them, but cant even see them).
    there seems to be some sort of bug. (yes, attach as windows friendly documents is selected).
    some have suggested that attaching multiple attachments using the command click method might be at fault.
    others have suggested that exporting to pdf might be a problem and the resulting pdf not always readable by windows users.
    can you give any suggestion that might ensure windows users can always open my attached PDFs?
    thanks

  • How can I send multiple attachments using SO_DYNP_OBJECT_SEND?

    Hi,
    I hope someone can offer advice on my problem.
    My requirement is to allow users to select one or more documents from an ALV grid.  I am then required to send these documents to multiple users via email using function module SO_DYNP_OBJECT_SEND.
    I can successfully send one document as an attachment.  However, I can't seem to figure out how to send multiple documents as attachments using SO_DYNP_OBJECT_SEND.  Is this done in the packing list?
    Is there some way to tell the program where the 1st attachment ends and the 2nd attachment starts?
    My attachment content is in i_att_cont.
      CALL FUNCTION 'SO_DYNP_OBJECT_SEND'
        EXPORTING
          object_hd_change = l_title
          object_type      = 'RAW'
          raw_editor       = abap_true
          starting_at_x    = '5'
          starting_at_y    = '1'
          ending_at_x      = '120'
          ending_at_y      = '20'
          edit_title       = 'X'
          external_commit  = abap_true
        TABLES
          objcont          = i_objcont
          rec_tab          = i_rec_tab
          packing_list     = i_packing_list
          att_cont         = i_att_cont
          exclude_fcode    = i_exclude_fcode
        EXCEPTIONS
          object_not_sent  = 1
          owner_not_exist  = 2
          parameter_error  = 3
          OTHERS           = 4.
    If you require more information, please let me know.  I will be happy to provide it.
    Thanks.

    I finally found the solution.
    The trick is to ensure you put the correct values in the body_start, body_num and objlen fields of the packing list.
    Each additional attachment should start (body_start) at the end of the last attachment + 1.
    The value for body_num is equal to the number of lines in the attachment being added.
    And the objlen field is calculated by multiplying the number of lines in the attachent * 255.
    Static data
       gs_packing_list-file_ext = lv_ext.
       gs_packing_list-transf_bin = 'X'.
       gs_packing_list-objla = sy-langu.
       gs_packing_list-objtp = 'EXT'.
       gs_packing_list-objdes = lv_filename.
       gs_packing_list-objnam = 'Attachment'.
       gs_packing_list-head_start = 1.
       gs_packing_list-head_num = 1.
    Body Start
       CLEAR lv_count.
       DESCRIBE TABLE gt_temp_att_cont LINES lv_count.
       gs_packing_list-body_start = lv_count + 1.
    Body Num + Object Length
       CLEAR lv_count.
       DESCRIBE TABLE gt_att_cont LINES lv_count.
       gs_packing_list-body_num = lv_count.
       gs_packing_list-objlen = lv_count * 255.
       APPEND gs_packing_list TO gt_packing_list.
    Hopefully this helps some desperate soul in the future.

  • Sending multiple attachments in one e-mail

    Is there a way to send multiple spreadsheets via mail without it opening a new e-mail message everytime? For example, If I create a spreadsheet and choose "Share", "Send via Mail", "PDF" - It pops up a new e-mail with the pdf already attached. That's great. However, I want to continue to add spreadsheets to the same e-mail. If I open another spreadsheet and do the same thing the attachment is in a new blank e-mail instead of being added to the e-mail that is already opened. Is there some type of preference setting that can help with this?

    Further thoughts:
    If by "spreadsheet" you mean "sheet", you can print and choose "Open PDF in Preview" (instead of printing to a printer) then drag the sheets/pages you want into an email message. You will want to select "all sheets" in the print window. You will want to open the Preview sidebar.
    If by "spreadsheet" you mean "document", printing to "Open PDF in Preview" creates new preview windows for me so it doesn't make the job any easier than dragging the PDFs from each email into one.
    If by "spreadsheet" you mean "table", you can copy/paste tables into an email, at least in Apple's Mail application. Best if the tables do not have the "name" checkbox checked or if the name is left justified. The names end up justified with respect to the email versus the table. You can also copy/paste multiple items from a sheet at once.

  • Sending multiple attachments in EMail adapter based on the segments:

    Hi,
    The scenario is from IDOC-Mail and the requirement is will we be able to send multiple files in the Email based on the segments ?
    Just assume that you have to create one file with the IDoc header data,
    and in addition to that one file per segment.
    Is this requirement possible?Please help .
    Thanks & Regards,
    Rajesh
    Edited by: rajeshkpnnaidu on Dec 16, 2010 8:33 AM

    Hi,
    In this case IDoc-file-mail, if we create multiple files based on the each IDoc segments,how we can combine all the files(created in local directory) which are related to 1 single IDoc  and send all of them in a single mail.
    Ex: if there are 20 files in local folder with 2 different IDoc segments then how we can filter based on each IDoc.
    Hope i am clear with my above description.
    Please help?
    BR,
    Praveen

Maybe you are looking for

  • Voice memos on iTunes

    Hello, I have an iphone 4 and I took a rather important voice memo of an interview, but its too long to send via email. In itunes I cant see it because I manage my music manually. How do I get the voice memo off my phone? If I turn sync on will I los

  • Significant delay at beginning of brush strokes on Microsoft Surface Pro 3?

    Using Photoshop Elements 10, it takes an abnormally long time for a brush stroke to begin registering. This is a bit difficult to explain, so here is a visual example: Here is what happens in photoshop elements 10 when I write 'hello': And here is wh

  • How to do a TableCellRenderer with Windows XP Look'n Feel ?

    In my application i use a sortable JTable view. In order to visualize the sorted column selected by user interaction i wrote my own TableCellRenderer implemantation to feature this with an icon in the table header which shows an arrow symbol for asce

  • Drag and Drop not working properly

    Hi My Drag and drop in itunes 10.5 is not working. i am managing my music and videos manually, but i cant drop them, every time i try, the mouse goes False. The Music i had are orignal. help me , i reinstalled it many times, its the same.

  • Database file changed ora-01251   how to solve?

    hai all, database file changed ora-01251 how to solve? suddenly changed when i try to connect Oracle Management server(OMS) thanks rcs ======= os:winxp db:Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production SQL> Recover database ORA-00283: rec