Sending mail with multiple attachments

hi.I wrote a code to send mail.but i need to send mail with multiple attachments.here is the code i wrote.what should i do to send the mail with multiple attachments.if i run this code iam able to send mails but not attachments.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 = "our local host";
     Properties props = System.getProperties();
     String msg_txt="";
     String strStatus="";
// byte[] bin=.....;
//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 );
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>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="to" size="72"><br>
<b>From :</b>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="from" size="72"><br>
<b>Subject :</b>&nbsp&nbsp&nbsp<input type="text" name="subject" size="72"><br>
<%=Attachfiles1%><br><%=Attachfiles2%><br><%=Attachfiles3%><br><br>
<b>Message:</b><br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<textarea rows="10" cols="50" name="message">
</textarea> <br><br>
<b>AttachedFile:</b>&nbsp<input type="file" name="fieldname1" value="filename" size="50"><br><br>
<b>AttachedFile:</b>&nbsp<input type="file" name="fieldname2" value="filename" size="50"><br><br>
<b>AttachedFile:</b>&nbsp<input type="file" name="fieldname3" value="filename" size="50"><br><br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="submit" name="attachfiles" value="Attachfiles">
<center>
<input type="submit" name="send" value="Send" >
</center>
</form>
</div>
</body>
</html>

Create a separate MimeBodyPart object for each attachment, rather than reusing
the same one over and over.

Similar Messages

  • Sending mail with multiple attachments in jsp

    hi .I wrote a code to send a mail in jsp.but now i need to send mails with multiple attachments.how can i send mail with multiple attachment.

    Create a separate MimeBodyPart object for each attachment, rather than reusing
    the same one over and over.

  • Sending mail with multiple attachment

    hi.
    i want to send mail with multiple attachment.
    i m succeed in sending multiple attachment but the second pdf is not open.
    its given error like "This file is damaged and could not be open.
    pls check my code. and
    give the solution....
    point should be assured...........
    hope all u r understand my problem..
    & tell me where is i m missing something.
    REPORT  YSDPASALE1_MAIL LINE-SIZE 110.
    data : year_month(6) type c.
    data : from_date like sy-datum,to_date like sy-datum.
    INITIALIZATION.
    year_month = sy-datum+0(6).
    CONCATENATE year_month '01' into from_date.
    to_date = sy-datum.
    ranges : temp for mkpf-budat.
    temp-low = from_date.
    temp-high = to_date.
    append temp to temp.
    DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
           jobname like TBTCJOB-JOBNAME,
           L_RELEASE(1) TYPE c.
    CONSTANTS : l_c_device(4)    VALUE 'LOCL'.
    DATA : t type i value 0.
    DATA : p_email1 like somlreci1-receiver,
            p_sender LIKE somlreci1-receiver.
    Data Declaration
    DATA: gd_recsize TYPE i,gd_recsize1 TYPE i.
    Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject  LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att1 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att2 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_desc1 TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des,
          gd_mtitle LIKE sodocchgi1-obj_descr.
    Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    DATA: BEGIN OF mailstr OCCURS 0,
            p_email like somlreci1-receiver,
          END OF mailstr.
    DATA: mailtab like STANDARD TABLE OF mailstr WITH HEADER LINE.
    DATA: ypp18tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
          ymis008tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
          ysd15tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
          ymis10tab like STANDARD TABLE OF mailstr WITH HEADER LINE.
    SUBMIT YSDPASALE1 with bdt in temp
                           to sap-spool
                          with line-size = '255'
                           with KEEP_IN_SPOOL = 'X'
                           with IMMEDIATELY = ' '
                           WITHOUT SPOOL DYNPRO
                           AND RETURN
       NEW-PAGE PRINT ON
       DESTINATION l_c_device
       IMMEDIATELY ' '
       KEEP IN SPOOL 'X'
       NEW LIST IDENTIFICATION 'X'
       NO DIALOG.
       new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
        PERFORM convert_spool_to_pdf.
        select yemail as p_email into CORRESPONDING FIELDS OF TABLE ymis008tab
          from ymail
          where ytcode = 'YMIS008'.
    ELSE.
       SKIP.
       WRITE:/ 'Program must be executed in background in-order for spool & mail sending',
               'request to be created.'.
      ENDIF.
    wait up to 3 seconds.
      submit YSD_MONTHLY_SALES
                                USING SELECTION-SET 'MAIL'
                                to sap-spool
                               with KEEP_IN_SPOOL = 'X'
                               with IMMEDIATELY = ' ' "SPACE
                               WITHOUT SPOOL DYNPRO
                               AND RETURN
       NEW-PAGE PRINT ON
       DESTINATION l_c_device
       IMMEDIATELY ' '
       KEEP IN SPOOL 'X'
       NEW LIST IDENTIFICATION 'X'
       NO DIALOG.
       new-page print off.
        IF sy-batch EQ 'X'.
        gd_attachment_desc1  = 'YMIS10'.
        gd_mtitle = 'Monthly Sales Report'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
        PERFORM convert_spool_to_pdf1.
       loop at it_mess_att.
        move it_mess_att1 to it_mess_att.
        APPEND it_mess_att.
       endloop.
       APPEND LINES OF it_mess_att1 to it_mess_att.
       free it_mess_att1.
        it_mess_att[] = it_mess_att1[].
        insert LINES OF it_mess_att1 into it_mess_att.
        APPEND LINES OF it_mess_att2 to it_mess_att .
         insert LINES OF it_mess_att1 into it_mess_att.
         insert LINES OF it_mess_att2 into it_mess_att.
       loop at ymis008tab into mailstr.
         p_email1 = mailstr-p_email.
          p_email1 = '[email protected]'.
           PERFORM process_email.
       endloop.
           clear mailstr.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
      ELSE.
        SKIP.
      ENDIF.
          FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
          FORM get_job_details                                          *
    FORM get_job_details.
    Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
          FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
    FORM convert_spool_to_pdf1.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att1 = gd_buffer.
        APPEND it_mess_att1.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
          FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      DESCRIBE TABLE it_mess_att1 LINES gd_recsize1.
      CHECK gd_recsize > 0 or gd_recsize1 > 0.
      PERFORM send_email." USING p_email1.
    perform send_email using p_email2.
    ENDFORM.
          FORM send_email                                               *
    -->  p_email                                                       *
    FORM send_email." USING p_email.
    CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = gd_attachment_desc1 .
    gd_attachment_desc = 'YPP18 - Daily Highlights'.
    CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Dear Sir,'.
      APPEND it_mess_bod.
    it_mess_bod        = ' '.
    APPEND it_mess_bod.
      it_mess_bod        = ' '.
      APPEND it_mess_bod.
      it_mess_bod        = 'kindly find the attached document'.
      APPEND it_mess_bod.
    it_mess_bod        = ' '.
    APPEND it_mess_bod.
    it_mess_bod        = 'Do not reply on this mail, It is generated from SAP'.
    APPEND it_mess_bod.
    it_mess_bod        = ' '.
    APPEND it_mess_bod.
      it_mess_bod        = ' '.
      APPEND it_mess_bod.
      it_mess_bod        = 'Regards,'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Arpit Shah'.
      APPEND it_mess_bod.
    If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                          it_mess_att1
                                    using "p_email
                                          gd_mtitle
                                         'Testing mail generated from SAP'
                                         'Daily Highlights Abstract Report - YPP18'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                              it_attach1
                                        using "p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1,w_doc_data1 like sodocchgi1.
    ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data1-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    For 2nd Attachments
    * Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach1 INDEX w_cnt.
      w_doc_data-doc_size = w_doc_data1-doc_size +
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach1 ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
    APPEND LINES OF it_attach1 to t_attachment.
      t_attachment[] = it_attach1[].
    APPEND LINES OF it_attach1 to t_attachment.
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 0.
      t_packing_list-body_start = 1.
    DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
    DESCRIBE TABLE it_mess_att LINES t_packing_list-body_num.
      DESCRIBE TABLE it_attach LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  'YMIS008'."ld_attdescription.
      t_packing_list-obj_name   =  'YMIS008'."ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
      clear t_packing_list.
    for 2 attachments
      data : a type i,b type i.
       a = t_packing_list-body_num.
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 0.
      t_packing_list-body_start = a + 1. "1
    DESCRIBE TABLE it_mess_att1 LINES t_packing_list-body_num.
      DESCRIBE TABLE it_attach1 LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  'YMIS10'."ld_attdescription.
      t_packing_list-obj_name   =  'YMIS10'."ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    a = t_packing_list-body_num.
    clear t_packing_list.
    * Create attachment notification
    t_packing_list-transf_bin = 'X'.
    t_packing_list-head_start = 1.
    t_packing_list-head_num   = 1.
    t_packing_list-body_start = a + 1.
    t_packing_list-body_num = t_packing_list-body_num + 1.
    DESCRIBE TABLE it_mess_att1 LINES t_packing_list-body_num.
    t_packing_list-body_num = a + t_packing_list-body_num .
    t_packing_list-doc_type   =  ld_format.
    t_packing_list-obj_descr  =  'YMIS10'."ld_attdescription.
    t_packing_list-obj_name   =  'YMIS10'."ld_attfilename.
    t_packing_list-doc_size   =  t_packing_list-body_num * 255.
    APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
    loop at ymis008tab into mailstr.
      t_receivers-receiver = mailstr-p_email.  "ld_email.
      t_receivers-receiver = p_email1.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'. "X   "Read Acknoledgement
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
    endloop.
       CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    Rgds.
    Arpit

    Hi Arpit,
    Take a look at the documentation of FM 'SO_DOCUMENT_SEND_API1' for parameter PACKING_LIST. I think you should set t_packing_list-head_num to a different value than 0 for the second attachment.
    Regards,
    John.

  • Sending email with multiple attachments

    Hi forum,
    I am able to send email with a single attachment using maildemo.sql from: http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
    But now I am trying to send email with more than 1 attachment and it does not work. My code that calls the above mentioned package is as follows:
    <code>
    PROCEDURE send (
    psender VARCHAR2,
    precipients VARCHAR2,
    pcc VARCHAR2,
    pbcc VARCHAR2,
    psubject VARCHAR2,
    pmessage VARCHAR2,
    pnumattach NUMBER) -- The number of attachments that need to be sent
    IS
    p_blob BLOB;
    p_filename VARCHAR2(200);
    p_filetype VARCHAR2(200);
    p_currSeq NUMBER;
    conn utl_smtp.CONNECTION;
    i NUMBER;
    j NUMBER;
    len NUMBER;
    BEGIN
    IF pnumattach > 1
    THEN
    conn := SEND_EMAIL_HELPER.begin_mail(
              sender => psender,
              recipients => precipients,
              subject => psubject,
              mime_type => send_email_helper.MULTIPART_MIME_TYPE);
    j := 0;
    SELECT seq_attach_transact_id.CURRVAL INTO p_currSeq FROM dual; -- seq_attach_transact_id is a primary key that identifies every single attachment in the table
    WHILE (j < pnumattach) LOOP
    p_currSeq := p_currSeq - j;
    SELECT blob_content INTO p_blob FROM wwdoc_document WHERE transaction_id = p_currSeq;
    SELECT name INTO p_filename FROM wwdoc_document WHERE transaction_id = p_currSeq;
    SELECT mime_type INTO p_filetype FROM wwdoc_document WHERE transaction_id = p_currSeq;
    SEND_EMAIL_HELPER.begin_attachment(
    conn => conn,
    mime_type => p_filetype,
    inline => TRUE,
    filename => p_filename,
    transfer_enc => 'base64');
    -- split the Base64 encoded attachment into multiple lines
    i := 1;
    len := DBMS_LOB.getLength(p_blob);
    WHILE (i < len) LOOP
    IF(i + SEND_EMAIL_HELPER.MAX_BASE64_LINE_WIDTH < len)THEN
    UTL_SMTP.Write_Raw_Data (conn,
    UTL_ENCODE.Base64_Encode(
    DBMS_LOB.SUBSTR(p_blob, SEND_EMAIL_HELPER.MAX_BASE64_LINE_WIDTH, i)));
    ELSE
    UTL_SMTP.Write_Raw_Data (conn,
    UTL_ENCODE.Base64_Encode(
    DBMS_LOB.SUBSTR(p_blob, (len - i)+1, i)));
    END IF;
    UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
    i := i + SEND_EMAIL_HELPER.MAX_BASE64_LINE_WIDTH;
    END LOOP;
    SEND_EMAIL_HELPER.end_attachment(conn => conn);
    END LOOP;
    SEND_EMAIL_HELPER.attach_text(
    conn => conn,
    data => pmessage,
    mime_type => 'text/html');
    SEND_EMAIL_HELPER.end_mail( conn => conn );
    ELSE
    utl_mail.send(psender,precipients,pcc,pbcc,psubject,pmessage);
    END IF;
    END send;
    </code>
    Can anyone please tell me where am i going wrong.
    Message was edited by:
    Monk

    The easiest is to send an e-mail with multiple attachments to yourself and then view the message in raw to see how it is formatted - how the boundaries work. what the boundary headers are, etc.
    Then you use that as a template for your PL/SQL code to generate a MIME body for an e-mail that has multiple attachments.
    To debug.. have your PL/SQL code send sample e-mails with multiple attachment to your account, view it in raw format and compare that to the original format you've based your template on.
    And none of this is really a PL/SQL issue.. it is all about formatting a valid MIME message for an e-mail.

  • Send Mail with Multiple Attachment

    How to send mail with multiple attachment. The documents are in a table column BLOB. Read and attach in to mail directly.
    We don’t want save the documents into hard disk and attach to mail. Please Help
    If you have java procedure or Pl/Sql Procedure. I think pl/sql can’t. So please mail me code to [email protected] mail id. Thank you.
    Thanks in advance
    Selvam

    Hi all
    Thanks for your reply, already tried this methods, Its not working for my requirements. Because my attachment is can be any type like ‘pdf’,’doc’,’txt’,’xls’,’jpg’,….
    And also the Utl_mail is very slow. Its using RAW type.
    I can use the javamail package to solve this problem, this javamail package needs to download into server from there you can attach thus documents into mail. But I want fetch the documents and ate the same time I want attach to a mail. Like yahoo attach or msn attachment.
    Thank you,
    Selvam

  • Sending mail with multiple dest., one is rejected - mail is rejected, why?

    Hello,
    I have a problem with my messaging server, while sending mails to multiple users, and one of them does not exist or is overquota.
    If one of the recipients gets rejected (email address does not exists or is overquota), the email is rejected (type J register) and no one receive it.
    any idea why messaging is doing this?
    The queue i'm using is configured like this:
    tcp_intranet notices 3 smtp nomx backoff "pt5m" "pt10m" "pt30m" subdirs 50 maxjobs 20 pool TCP_INTRANET_POOL recipient
    limit 256 maytlsserver maysaslserver allowswitchchannel saslswitchchannel tcp_auth identnone noexquota
    tcp_intranet-daemonand the version of messaging
    imsimta version
    Sun Java(tm) System Messaging Server 6.2-4.03 (built Sep 22 2005)
    libimta.so 6.2-4.03 (built 04:14:30, Sep 22 2005)
    SunOS smtp07 5.9 Generic_118559-28 i86pc i386 i86pc
    root@smtp:/var/opt/SUNWmsgsr/config > thanks in advance
    Xavier

    xavierm wrote:
    If one of the recipients gets rejected (email address does not exists or is overquota), the email is rejected (type J register) and no one receive it.If an individual email account is overquota or an email address doesn't exist, only that RCPT TO: attempt for that individual address will be rejected -- this does not mean the email cannot be delivered to the valid recipients.
    It is up to the email client to determine how an individual rejected recipient address is handled, i.e. should it continue sending the email or give up and alert the user.
    any idea why messaging is doing this?This is how all efficient email servers operate. What is the email client that you are using to send the email?
    The queue i'm using is configured like this:
    tcp_intranet notices 3 smtp nomx backoff "pt5m" "pt10m" "pt30m" subdirs 50 maxjobs 20 pool TCP_INTRANET_POOL recipient
    limit 256 maytlsserver maysaslserver allowswitchchannel saslswitchchannel tcp_auth identnone noexquota
    tcp_intranet-daemon
    The noexquota option does nothing on Sun Messaging Server:
    "Note that these options have no effect on delivery to Messaging Server mailboxes on any platform. "
    http://msg.wikidoc.info/index.php/Exquota%2C_noexquota%2C_holdexquota_Channel_Options
    You may however want to try the acceptalladdresses channel option:
    http://msg.wikidoc.info/index.php/Acceptalladdresses%2C_acceptvalidaddresses_Channel_Options
    Regards,
    Shane.

  • Sending mail with 2 attachments

    Hi All,
            I have a requirement where I have to send a mail with 2 attachments. Both attachments should be excel sheets.
    Iam using the function module
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = gd_doc_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = gd_sent_all
        TABLES
          packing_list               = it_packing_list
          contents_txt               = it_message
         contents_bin               = it_attachment
          receivers                  = it_receivers
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
    I don't know where to pass another attachment.
    How can it be done?
    Kindly help me.
    Regards,
    Krithika

    Hi,
    Try this code.
    you have to populate both packing_list and contents_bin internal tables before passing to the fm SO_NEW_DOCUMENT_ATT_SEND_API1
    FORM CONVERT_OTF_TO_PDF TABLES OTFTAB STRUCTURE OTF.
      CLEAR: SOOD, W_LINES, CONTENT_IN, CONTENT_OUT.
      REFRESH: CONTENT_IN, CONTENT_OUT.
      DESCRIBE TABLE OTFTAB LINES W_LINES.
      SOOD-OBJLEN = W_LINES.
      REFRESH: CONTENT_IN, CONTENT_OUT.
      CLEAR: CONTENT_IN, CONTENT_OUT.
       CONTENT_IN[] = OTFTAB[].
        CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
             EXPORTING
                  FORMAT_SRC      = 'OTF'
                  FORMAT_DST      = 'PDF'
                  DEVTYPE         = 'HPLJ5SI'
    *         FUNCPARA        =
                  LEN_IN          = SOOD-OBJLEN
    *    IMPORTING
    *         LEN_OUT         =
             TABLES
                  CONTENT_IN      = CONTENT_IN
                  CONTENT_OUT     = CONTENT_OUT
             EXCEPTIONS
                  ERR_CONV_FAILED = 1
                  OTHERS          = 2.
      REFRESH OBJBIN. CLEAR OBJBIN.
      IF GV_SUMMARY <> 'X'.
        OBJBIN[] = CONTENT_OUT[].
      ELSE.
        REFRESH CONTENT_OUT.
        CLEAR CONTENT_OUT.
      ENDIF.
      REFRESH: CONTENT_IN, OBJPACK.
      CLEAR: CONTENT_IN, OBJPACK.
      DOC_CHNG-OBJ_NAME = TEXT-003.
      IF SY-SYSID NE 'S4P'.
       IF DOC_CHNG-OBJ_DESCR IS  INITIAL.
          DOC_CHNG-OBJ_DESCR = TEXT-004.
        ELSE.
          IF GV_SUMMARY = 'X'.
           DOC_CHNG-OBJ_DESCR = TEXT-012.
          ENDIF.
        ENDIF.
      ENDIF.
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ TABLE OBJTXT INDEX TAB_LINES.
      DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    * Fill the fields of the packing_list for the main document:
        CLEAR  OBJPACK.
        DESCRIBE TABLE OBJBIN LINES TAB_LINES.
       OBJPACK-TRANSF_BIN = 'X'.
        OBJPACK-HEAD_START = 1.
        OBJPACK-HEAD_NUM = 0.
        OBJPACK-BODY_START = 1.
        OBJPACK-BODY_NUM = TAB_LINES.
        OBJPACK-DOC_TYPE = 'XLS'.
        OBJPACK-OBJ_NAME = 'Attachment'.
        OBJPACK-OBJ_DESCR = C_PAYER.
        READ TABLE OBJBIN INDEX TAB_LINES.
        DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJBIN ).
        OBJPACK-DOC_SIZE = DOC_SIZE.
        APPEND OBJPACK.
        CLEAR  OBJPACK.
        DESCRIBE TABLE OBJBIN LINES TAB_LINES.
       OBJPACK-TRANSF_BIN = 'X'.
        OBJPACK-HEAD_START = 1.
        OBJPACK-HEAD_NUM = 0.
        OBJPACK-BODY_START = 1.
        OBJPACK-BODY_NUM = TAB_LINES.
        OBJPACK-DOC_TYPE = 'XLS'.
        OBJPACK-OBJ_NAME = 'Attachment'.
        OBJPACK-OBJ_DESCR = C_PAYER.
        READ TABLE OBJBIN INDEX TAB_LINES.
        DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJBIN ).
        OBJPACK-DOC_SIZE = DOC_SIZE.
        APPEND OBJPACK.
        REFRESH RECLIST.
        CLEAR RECLIST.
    ** get E-mail address
          IF NOT P_EMAIL IS INITIAL.
            RECIPIENT_INT-ADDRESS = P_EMAIL.
          ENDIF.
            RECLIST-RECEIVER = RECIPIENT_INT.
            RECLIST-REC_TYPE = 'U'.
            APPEND RECLIST.
    * SEND THE DOCUMENT BY CALLING THE SAPOFFICE API1 MODULE
    * FOR SENDING DOCUMENTS WITH ATTACHMENTS
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = DOC_CHNG
                PUT_IN_OUTBOX              = 'X'
           IMPORTING
                SENT_TO_ALL                = SENT_TO_ALL
           TABLES
                PACKING_LIST               = OBJPACK
                OBJECT_HEADER              = OBJHEAD
                CONTENTS_BIN               = OBJBIN
                CONTENTS_TXT               = OBJTXT
                RECEIVERS                  = RECLIST
           EXCEPTIONS
                TOO_MANY_RECEIVERS         = 1
                DOCUMENT_NOT_SENT          = 2
                OPERATION_NO_AUTHORIZATION = 4
               OTHERS                     = 99.
    Regards,
    Sailaja.

  • Send email with multiple attachments using MS outlook

    Hi,
    Is it possible to send an email with multiple attachments using MS outlook. (Using activex)
    Regards,
    Neha

    nehrnul wrote:
    Hey thanks for the reply. I'll try that way also.
    but currently my requirement is to send email using MS Outlook. And I found 1 solution using invoke node
    Regards,
    Neha
    That' "requirement" sounds like it was written by someone who is trying to drive the design of the application.  Without knowing your personal situation it's hard for me to say, but if I had to guess I would say the real requirement is to send an email with multiple attachements, and the person giving that requirement thought sending it through Outlook would be the best way.  You should get clairification on what the real intend of that requirement is.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Send mail with multiple excel attachments

    hello experts,
    i need to send e-mail with three excel attachments. is it possible, if so, how can i do that?
    early replies appreciated.
    regards,
    Murat Kaya

    Hi murat,
    here a simple example with 3 xls-att.
    DATA: SEND_REQUEST       TYPE REF TO CL_BCS.
    DATA: SUBJECT            TYPE SO_OBJ_DES.
    DATA: ATT_TYPE           TYPE SOODK-OBJTP.
    DATA: IT_TEXT            TYPE BCSY_TEXT.
    DATA: WA_TEXT            LIKE SOLI.
    DATA: IT_BIN             TYPE SOLIX_TAB.
    DATA: WA_BIN             TYPE SOLIX.
    DATA: DOCUMENT           TYPE REF TO CL_DOCUMENT_BCS.
    DATA: SENDER             TYPE REF TO CL_SAPUSER_BCS.
    DATA: RECIPIENT          TYPE REF TO IF_RECIPIENT_BCS.
    DATA: BCS_EXCEPTION      TYPE REF TO CX_BCS.
    DATA: SENT_TO_ALL        TYPE OS_BOOLEAN.
    Bytes der Datei
    DATA: IT_LENGHT          TYPE SO_OBJ_LEN.
    DATA: N10(10)            TYPE N.
    CONSTANTS: CON_NEWL TYPE ABAP_CHAR1
                        VALUE CL_ABAP_CHAR_UTILITIES=>NEWLINE,
               CON_TAB  TYPE ABAP_CHAR1
                        VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    START-OF-SELECTION.
      PERFORM MAIN.
      PERFORM RSCONN01_EXECUTE.
    END-OF-SELECTION.
    FORM MAIN.
      TRY.
          SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
          PERFORM HEAD_CONT.
    PERFORM XLS_ATT.
    PERFORM XLS_ATT1.
    PERFORM XLS_ATT2.
    Dokument (mit Anhang) setzen
          CALL METHOD SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
    Absender setzen
          SENDER = CL_SAPUSER_BCS=>CREATE( SY-UNAME ).
          CALL METHOD SEND_REQUEST->SET_SENDER
            EXPORTING
              I_SENDER = SENDER.
    Empfänger setzen
    email-Empfänger
          RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
                                            'yourmailaddress' ).
          CALL METHOD SEND_REQUEST->ADD_RECIPIENT
            EXPORTING
              I_RECIPIENT = RECIPIENT
              I_EXPRESS   = 'X'.
    Dokument senden
          CALL METHOD SEND_REQUEST->SEND(
            EXPORTING
              I_WITH_ERROR_SCREEN = 'X'
            RECEIVING
              RESULT              = SENT_TO_ALL ).
          COMMIT WORK.
    Sende-Error abfangen
        CATCH CX_BCS INTO BCS_EXCEPTION.
          WRITE: 'Fehler aufgetreten.'(001).
          WRITE: 'Fehlertyp:'(002), BCS_EXCEPTION->ERROR_TYPE.
          EXIT.
      ENDTRY.
    ENDFORM.                    "main
    FORM HEAD_CONT.
      CLEAR: IT_TEXT[], WA_TEXT, SUBJECT.
      ATT_TYPE = 'RAW'.
      CONCATENATE 'Betreffzeile am' SY-DATUM 'um' SY-UZEIT
      INTO SUBJECT SEPARATED BY SPACE.
      WA_TEXT = 'Hello!'.
      APPEND WA_TEXT TO IT_TEXT.
      DESCRIBE TABLE IT_TEXT LINES N10.
      N10 = ( N10 - 1 ) * 255 + STRLEN( WA_TEXT ).
      IT_LENGHT = N10.
      DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
                I_TYPE    = ATT_TYPE
                I_TEXT    = IT_TEXT
                I_LENGTH  = IT_LENGHT
                I_SUBJECT = SUBJECT ).
    ENDFORM.                    "HEAD_CONT
    FORM XLS_ATT.
      DATA: BEGIN OF ITAB OCCURS 0,
            MATNR     LIKE MARA-MATNR,
            MTART     LIKE MARA-MTART,
            MATKL     LIKE MARA-MATKL,
            BRGEW     LIKE MARA-BRGEW,
          END   OF ITAB.
      DATA: BRGEW(18).
      CLEAR: IT_BIN[], WA_BIN, SUBJECT.
      SELECT MATNR MTART MATKL BRGEW INTO TABLE ITAB
             FROM MARA UP TO 10 ROWS.
      CONCATENATE 'Material'      CON_TAB
            'Materialart'   CON_TAB
            'Warengruppe'   CON_TAB
            'Bruttogewicht' CON_NEWL
              INTO WA_BIN.
      APPEND WA_BIN TO IT_BIN.
      LOOP AT ITAB.
        WRITE ITAB-BRGEW TO BRGEW.
        CONCATENATE ITAB-MATNR CON_TAB
                    ITAB-MTART CON_TAB
                    ITAB-MATKL CON_TAB
                         BRGEW CON_NEWL
                    INTO WA_BIN.
        APPEND WA_BIN TO IT_BIN.
      ENDLOOP.
      ATT_TYPE = 'XLS'.
      SUBJECT = 'My XLS attachment'.
      DESCRIBE TABLE IT_BIN LINES N10.
      N10 = ( N10 - 1 ) * 255 + STRLEN( WA_BIN ).
      IT_LENGHT = N10.
      CALL METHOD DOCUMENT->ADD_ATTACHMENT
        EXPORTING
          I_ATTACHMENT_TYPE    = ATT_TYPE
          I_ATT_CONTENT_HEX    = IT_BIN
          I_ATTACHMENT_SIZE    = IT_LENGHT
          I_ATTACHMENT_SUBJECT = SUBJECT.
    ENDFORM.                    "XLS_ATT
    FORM XLS_ATT1.
      DATA: BEGIN OF ITAB OCCURS 0,
            KUNNR     LIKE KNA1-KUNNR,
          END   OF ITAB.
      CLEAR: IT_BIN[], WA_BIN, SUBJECT.
      SELECT KUNNR INTO TABLE ITAB
             FROM KNA1 UP TO 10 ROWS.
      CONCATENATE 'Kunde' CON_NEWL INTO WA_BIN.
      APPEND WA_BIN TO IT_BIN.
      LOOP AT ITAB.
        CLEAR WA_BIN.
        CONCATENATE ITAB-KUNNR CON_NEWL INTO WA_BIN.
        APPEND WA_BIN TO IT_BIN.
      ENDLOOP.
      ATT_TYPE = 'XLS'.
      SUBJECT = 'My XLS attachment1'.
      DESCRIBE TABLE IT_BIN LINES N10.
      N10 = ( N10 - 1 ) * 255 + STRLEN( WA_BIN ).
      IT_LENGHT = N10.
      CALL METHOD DOCUMENT->ADD_ATTACHMENT
        EXPORTING
          I_ATTACHMENT_TYPE    = ATT_TYPE
          I_ATT_CONTENT_HEX    = IT_BIN
          I_ATTACHMENT_SIZE    = IT_LENGHT
          I_ATTACHMENT_SUBJECT = SUBJECT.
    ENDFORM.                                                    "XLS_ATT1
    FORM XLS_ATT2.
      DATA: BEGIN OF ITAB OCCURS 0,
            LIFNR     LIKE LFA1-LIFNR,
          END   OF ITAB.
      CLEAR: IT_BIN[], WA_BIN, SUBJECT.
      SELECT LIFNR INTO TABLE ITAB
             FROM LFA1 UP TO 10 ROWS.
      CONCATENATE 'Lieferant' CON_NEWL INTO WA_BIN.
      APPEND WA_BIN TO IT_BIN.
      LOOP AT ITAB.
        CLEAR WA_BIN.
        CONCATENATE ITAB-LIFNR CON_NEWL INTO WA_BIN.
        APPEND WA_BIN TO IT_BIN.
      ENDLOOP.
      ATT_TYPE = 'XLS'.
      SUBJECT = 'My XLS attachment2'.
      DESCRIBE TABLE IT_BIN LINES N10.
      N10 = ( N10 - 1 ) * 255 + STRLEN( WA_BIN ).
      IT_LENGHT = N10.
      CALL METHOD DOCUMENT->ADD_ATTACHMENT
        EXPORTING
          I_ATTACHMENT_TYPE    = ATT_TYPE
          I_ATT_CONTENT_HEX    = IT_BIN
          I_ATTACHMENT_SIZE    = IT_LENGHT
          I_ATTACHMENT_SUBJECT = SUBJECT.
    ENDFORM.                                                    "XLS_ATT2
    FORM RSCONN01_EXECUTE.
      WAIT UP TO 2 SECONDS.
      SUBMIT RSCONN01 WITH MODE   = 'INT'
                      WITH OUTPUT = ' '
                      AND  RETURN.
    ENDFORM.                    "RSCONN01_EXECUTE
    Hope it helpd.
    If you need more than 3 ATT inser more ATT-Forms.
    Regards, Dieter

  • SAP PI7.31 : Mail with multiple attachments - how to process via UDF

    Hi
    wondering how I can approach this problem.   I have to read an Email with any number of attachments  - it can have between 1 and 4 or maybe more of different types (CSV,XLS,PDF,ZIP).  I need to read this email and extract the attachments to a folder.
    Just to let you know I have done this OK for an email that I know only has 2 attachments ! Works perfectly - just no good for ?n? attachments !
       Mail Sender has AF_Modules/MultipartHeaderBean to add payload Attributes
       The message is sent to 2 Receivers
       Each Receiver File adapter then uses AF_Modules/DynamicConfigurationBean and AF_Modules/PayloadSwapBean
    Problem is that when I do not know how many attachments there are.  So I will have to write a Java UDF mapping, perhaps using the classTransformationInput.
    My question is : To create a Java UDF what should be structure of a sent Email message Type look like so I can feed that into a UDF to check what payload attachments there are etc ?.

    As long as you use java mapping, you can have any dummy structures for your interfaces.
    But, if you prefer to use graphical mapping with UDF, then you should have some valid structures for your mail and file interfaces. e.g., mail pack XSD for mail interface as metioned by Indrajit Sarkar
    and again the same structure for the file interface as well so that you can have one to one mapping an then make use of UDF code from the article. Use payload swap bean in the receiver file channel to replace xml payload with Zipped attachments and then finally use script to unzip this zip file.
    Rgds,
    Praveen Gujjeti

  • File to Mail with multiple attachments

    Hi All,
    I am doing file to mail scenario in which iam including attachments.
    I am able to send one attachment(i.e., .txt) from file to mail.
    My requirement is i need to send both .txt and .xls .Please let me know the procedure for sending multiple attachments(probabaly without any abap coding or .jar files usage).
    regards
    Madhu

    Hi Madhu,
         Using the default modules PayloadSwapBean and MessageTransformBean you can able to send multiple attachments.
    swap.keyName  :payload-name or payload-description or content-type, content-description. swap.keyValue: If you have  a multiple attachments then give the multiple key value.
    Like you have payload name
      Attachment1, Attachment2 then
    swap.keyName  payload-name
    swap.keyValue  Attachment1, Attachment2
    Using the MessageTransformBean you can able to change the file name.
    PayloadSwapBean:
    [http://help.sap.com/saphelp_nw70/helpdata/EN/2e/bf37423cf7ab04e10000000a1550b0/content.htm]
    MessageTransformBean:
    [http://help.sap.com/saphelp_nw70/helpdata/EN/57/0b2c4142aef623e10000000a155106/content.htm]
    Regards,
    Prakasu

  • Send mail with 2 attachments

    Hi all,
    I need to send an email with 2 attachments: 1 is a sapscript converted into PDF, and the other one is an Excel sheet.
    Is it possible?
    I think I almost have it, with function SO_NEW_DOCUMENT_ATT_SEND_API1, and table field pack_list-head_start, but I can see the PDF and not the Excel.
    Thanks in advance,
    Rafael Llabré

    This is possible, however for every attachment you need for example a new pack list. So the thing you do for ONE attachment has to be repeated for every new attachment.
    have a look at this thread:
    https://forums.sdn.sap.com/click.jspa?searchID=10795451&messageID=4850757
    Edited by: Micky Oestreich on Apr 16, 2008 10:03 AM

  • Sending Mail with multiple forward accounts

    I currently have approximately 4 email accounts being forwarded to my gmail account. This is the account I use through Mail. Is it possible to send mail out that is, say from my school email account and still have it say that it is from my school email account instead of from the gmail account? I really need this feature. Please Help

    WJAADAMS wrote:
    I currently have approximately 4 email accounts being forwarded to my gmail account. This is the account I use through Mail. Is it possible to send mail out that is, say from my school email account and still have it say that it is from my school email account instead of from the gmail account?
    if you send an email from your school account it will say that it's from your school account. if you want to send an email from gmail but have it say that it's from your school account, this is impossible. The best you can do is include a reply-to field so that if someone replies to it it will go to your school address.

  • Sending mail with multiple recipients as one mail?

    The project I'm working on to migrate users to the new 7.x messaging platform keeps asking me to do some special configurations.
    I got this question today...
    xxxxxxxxxxxxxxxxxxxxxxxxx
    4. As inquired, when sent from SunMail to/copying multiple addresses, the outgoing email is replicated as many as the number of addressees
    (For example, if you are sending an email to 10 people, the email is sent as 10 emails)
    In the Exchange system, email to multiple recipients is replicated in the Top Mail Server. But in SunMail, such email is replicated to 10 emails when being sent.
    We want SunMail emails to remain as a single email when being sent and only to be replicated to each recipient in the Top Mail Server.
    This may be dependent on the specs of mail software, which means it may not be able to fix, but please confirm.
    xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    The "top mail server" is just some postoffice product, appliance type mta for sendmail.
    Is there anyways to pass along the email without expanding the recipients into individual mails?
    Thanks.
    -Ray

    Ray_Cormier wrote:
    Hey Kelly, longtime no chat. Thanks for such a detailed and informative answer. I read over the link, that explains a lot. The old system is a 6.3. Unfortunately I have a very limited access to the old production systems and can't do much. Otherwise information is like pulling teeth around here. I've copied over all the configuration files and I am going through that stuff now.I recommend you compare the old MS6.3 configuration with the new MS7u3 default (configuration) settings and make changes to the MS7u3 settings only where necessary. Using the old MS6.3 settings may no longer be appropriate for the new environment.
    I think the main thing here, is that the default behavior in the proposed 7.x system will give them the results they seek, does that sounds like a fair assumption?Taking a step back I question the initial statement:
    "4. As inquired, when sent from SunMail to/copying multiple addresses, the outgoing email is replicated as many as the number of addressees".
    From a strictly performance/storage perspective it makes no sense to "replicate" an email and the MTA goes to great lengths to avoid such replication where possible. Kelly has pointed out one scenario where replication will occur ("single" channel keyword) but this is not enabled by default (for good reason). There could be other causes e.g. conversion channel or sieve filters or spam filtering that operates at the envelope recipient level.
    So if this "replication" behaviour is occurring in the old environment then without understanding why it is occurring you cannot assume it won't occur in the new environment -- especially if you are copying across the old config files.
    Regards,
    Shane.

  • Sending mails with binary attachments

    Hi!
    I've to implement a routine for sending an email with attachments.
    These attachments can be PDF- or HTML-Files. Sometimes the last of the PDF-Attachments could not be opened when receiving the mail (it can't be open in the SOST as well).
    My coding is:
          loop at lt_doks.
            select single * from toadv where ar_object eq lt_doks-ar_object.
            call function 'ARCHIVOBJECT_GET_TABLE'
              exporting
                archiv_id                = lt_doks-archiv_id
                document_type            = toadv-doc_type
                archiv_doc_id            = lt_doks-arc_doc_id
              importing
                length                   = l_length
              tables
                archivobject             = l_image_tab
              exceptions
                error_archiv             = 1
                error_communicationtable = 2
                error_kernel             = 3
                others                   = 4.
            clear objpack.
            perform convert_document tables l_image_tab
                                            objbin
                                     using tab_lines_new
                                           i_pernr
                                           i_reinr
                                           l_subrc.
            if l_subrc ne 0.
              raise convert_error.
            endif.
            objpack-transf_bin = 'X'.
            objpack-head_start = 3.
            objpack-head_num = 0.
            objpack-body_start = tab_lines + 1.
            objpack-body_num = tab_lines_new.
            objpack-doc_type = toadv-doc_type.
            objpack-obj_name = 'Attachment'.
            objpack-obj_descr = lt_doks-objecttext.
            objpack-doc_size = tab_lines_new * 255."l_length.
            append objpack.
            tab_lines = tab_lines + tab_lines_new.
            clear tab_lines_new.
          endloop.
        endif.
      endif.
      if not document_data-obj_descr is initial.
    jetzt wird's ernst -> Mail versenden
        call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          exporting
            document_data              = document_data
            put_in_outbox              = ' '
            commit_work                = 'X'
          tables
            packing_list               = objpack
            contents_txt               = daten
            contents_bin               = objbin
            receivers                  = receivers
          exceptions
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5
            x_error                    = 6
            enqueue_error              = 7
            others                     = 8.
      endif.
    form convert_document tables p_image_tab structure docs
                                 p_objbin structure solisti1
                          using  p_lines
                                 p_pernr
                                 p_reinr
                                 p_subrc.
      data: l_filename like filename-fileextern.
      clear p_lines.
      call function 'FILE_GET_NAME'
        exporting
          client           = sy-mandt
          logical_filename = 'Z_HRTV_CONVERT'
          operating_system = sy-opsys
          parameter_1      = p_pernr
          parameter_2      = p_reinr
        importing
          file_name        = l_filename
        exceptions
          file_not_found   = 1
          others           = 2.
      if sy-subrc ne 0.
        p_subrc = sy-subrc.
        exit.
      endif.
    Schreiben der Datei
      open dataset l_filename for output in binary mode.
      loop at p_image_tab.
        transfer p_image_tab to l_filename.
      endloop.
      close dataset l_filename.
      refresh p_image_tab.
      clear p_image_tab.
    Lesen der Datei
      open dataset l_filename for input in binary mode.
      do.
        read dataset l_filename into p_objbin.
        if sy-subrc <> 0.
          if not p_objbin is initial.
            append p_objbin.
            clear p_objbin.
            add 1 to p_lines.
          endif.
          exit.
        endif.
        append p_objbin.
        clear p_objbin.
        add 1 to p_lines.
      enddo.
      close dataset l_filename.
    Löschen der Datei
      delete dataset l_filename.
    endform.                    " convert_document
    Can anybody give me hint?
    Thanks a lot!
    Peter

    Hi,
    Whether your objpack-doc_type is coming correctly for the last PDF attachment?
    Thanks
    aRs

Maybe you are looking for