E mail with PDF attachment

Hi ,
I have a requirement where I need to send the comments that are entered in the portal to a list of e mail ids . I tried with spool and it is not working . I tried even with the class CL_BCS
same problem. Could you please suggest me ?
I heard that If i write the content to App server and then read it in the binary mode , probably it works.
But when I read the file in binary mode , sy-subrc is always becoming 4 .
Could you please help me out??
Thanks and Regards
Ravi

Hi Ravi,
        Check the authorization rights for the application server. Can you able to write the content in the Applicaiton server. if so then make a internal table with a single field. so that loop that file and dump the content in the internal table.
Thanks
Yogesh

Similar Messages

  • How to send a mail with PDF attachment

    Hello
    Good Day!
    We have a requirement to send the mail with pdf attachment. Pdf file will be remain same for all mails and it will be placed at server. We are on R12.4 and below is the database information :
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE 11.2.0.3.0 Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    Thanks a ton for your anticipated help!
    Thanks
    Gaurav

    The word URGENT is considered as rude in this forum.. Nobody here is getting paid for the ansers they are giving..
    Just have a look at These threads.Those will help you.

  • Send Mail with PDF Attachment in ABAP

    Hi Experts,
    I have a requirement where I need to convert internal table data into PDF format and send it as an E-Mail with PDF attachment to Outlook mail using ABAP.
    How do I achieve this .
    Can anyone send me example code for doing this.
    Thanks
    Kumar

    hiii
    check following code for PDF attachment and mail
    ** Check for any ATTACHMENTS...
    IF d_desired_type = 'RAW'.           " Set to RAW?
    *    PERFORM convert_to_abaplist.       " YES - convert it
      ENDIF.                               " end...
      IF d_desired_type = 'ALI'.           " Set to ALI?
        PERFORM convert_to_alilist.        " YES - convert it
      ENDIF.                               " end...
    * Check for any ATTACHMENTS...
      IF NOT t_soli[] IS INITIAL.          " attachment?
        h_real_type = d_desired_type.      " ENABLE
        h_transf_type = 'X'.               " Transfer type BINARY...
    *   Write PDF/ALI formatted data to BINARY table...
        t_con_bin[] = t_soli[].
    *   Add Packing List (attachment) for PDF...
        DESCRIBE TABLE t_con_bin LINES h_tab_cntr.
        READ TABLE t_con_bin INDEX h_tab_cntr.
        h_doc_data-doc_size = h_doc_data-doc_size
                            + ( ( h_tab_cntr - 1 )
                            * 255 + STRLEN( t_con_bin ) ).
        h_doc_data-obj_descr  = mail_subject.
        h_body_start = 1.
        h_body_num = h_tab_cntr.
    *   Write RAW data if that's what it is (adds to TEXT)...
        IF h_real_type = 'RAW'.
          DESCRIBE TABLE t_con_text LINES h_body_start.
          h_body_start = h_body_start + 1.
          h_transf_type = space.           " Transfer type TEXT...
          LOOP AT t_con_bin.               " Zip thru TEXT stuff
            t_con_text = t_con_bin.        " set TEXT table header..
            APPEND t_con_text.             " add to what's there!
          ENDLOOP.
          CLEAR: t_con_bin.                " clear BINARY header..
          REFRESH: t_con_bin.              " reset BINARY table...
        ENDIF.
        CLEAR t_pak_list.
        IF h_transf_type = 'X'.            " Binary=PDF/ALI?
          t_pak_list-transf_bin = 'X'.
          t_pak_list-head_start = 1.
          t_pak_list-head_num   = 0.
          t_pak_list-body_start = 1.
          t_pak_list-body_num   = h_tab_cntr.
          t_pak_list-doc_type   = h_real_type.
          t_pak_list-obj_name   = 'ATTACHMENT'.
          t_pak_list-obj_descr  = 'Document'(001).
          t_pak_list-doc_size   = ( h_tab_cntr - 1 )
                                * 255 + STRLEN( t_con_bin ).
        ELSE.
          DESCRIBE TABLE t_con_text LINES h_tab_cntr.
          READ TABLE t_con_text INDEX h_tab_cntr.
          t_pak_list-transf_bin = ' '.     " Binary=RAW
          t_pak_list-head_start = 1.
          t_pak_list-head_num   = 0.
          t_pak_list-body_start = h_body_start.
          t_pak_list-body_num   = h_tab_cntr.
          t_pak_list-doc_type   = h_real_type.
          t_pak_list-obj_name   = 'ATTACHMENT'(002).
          t_pak_list-obj_descr  = 'Report'(003).
          t_pak_list-doc_size   = ( h_body_num - 1 )
                                * 255 + STRLEN( t_con_text ).
        ENDIF.
        APPEND t_pak_list.
      ENDIF.
    * Send the EMAIL out with SAP function...
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = h_doc_data
          put_in_outbox              = 'X'
    *      commit_work                = 'X'
        TABLES
          packing_list               = t_pak_list
          contents_bin               = t_con_bin
          contents_txt               = t_con_text
          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.
      IF syst-subrc NE 0.
    *    RAISE send_failed.
        CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
          EXPORTING
            msg_arbgb = '00'
            msg_nr    = '001'
            msg_ty    = 'E'
            msg_v1    = 'O/P Could not be issued '(001)
            msg_v2    = ' Due to No Mail ID'(002)
            msg_v3    = syst-msgv3
            msg_v4    = syst-msgv4
          EXCEPTIONS
            OTHERS    = 1.
    * Check General incompletion status of the header
        IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ELSE.
          WRITE : 'SENT'.
        ENDIF.
      ELSE.
    *    commit work.
      ENDIF.
    ENDFORM.                               " SEND_MAIL_FAX
    *&      Form  convert_otf_2_pdf
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_otf_2_pdf .
      DATA: "t_line            LIKE tline OCCURS 0 WITH HEADER LINE,
            t_objcont         LIKE soli  OCCURS 0 WITH HEADER LINE,
            d_doc_size(12)    TYPE c,
            d_fle1(2)         TYPE p,
            d_fle2(2)         TYPE p,
            d_off1            TYPE p,
            d_hltlines        TYPE i,
            d_hfeld(500)      TYPE c,
            w_indx            LIKE sy-tabix.
      CLEAR: t_line, t_objcont, d_off1.
      REFRESH: t_line, t_objcont.
    * Check/set DEFAULT Desired-type attachment...
      IF d_desired_type IS INITIAL.        " Entered Desired type?
        d_desired_type = 'PDF'.            " NO  - default to PDF
      ENDIF.                               "
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = d_desired_type
        IMPORTING
          bin_filesize          = d_doc_size
        TABLES
          otf                   = t_itcoo
          lines                 = t_line
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          OTHERS                = 4.
      IF sy-subrc > 0.
        RAISE otf_convert_failed.
      ENDIF.
    ENDFORM.                               " convert_otf_2_pdf
    *&      Form  convert_otf_2_pdf_sx
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_otf_2_pdf_sx .
      DATA:
        t_otf          LIKE solisti1 OCCURS 0 WITH HEADER LINE,"ENABLE
        t_pdf          LIKE tline    OCCURS 0 WITH HEADER LINE,"ENABLE
        doc_size(12)   TYPE n,
        len_out        TYPE i,
        x_real         LIKE  soodk-objtp,
        x_idx_b        LIKE sy-tabix,
        x_idx_e        LIKE sy-tabix.
      IF d_desired_type = 'PDF'.
        d_desired_type = 'OTF'.
      ENDIF.
      CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
        EXPORTING
          rqident              = d_spool_id
          desired_type         = d_desired_type
        IMPORTING
          real_type            = x_real
        TABLES
          buffer               = t_otf
          buffer_pdf           = t_pdf
        EXCEPTIONS
          no_such_job          = 1
          job_contains_no_data = 2
          selection_empty      = 3
          no_permission        = 4
          can_not_access       = 5
          read_error           = 6
          type_no_match        = 7
          OTHERS               = 8.
      IF sy-subrc <> 0.
        IF sy-subrc = 1.
          RAISE invalid_spool_id.
        ELSE.
          RAISE otf_convert_failed.
        ENDIF.
      ENDIF.
    * Check Desired-Type vs. Real-Type (if any)...
      IF d_desired_type IS INITIAL.
        IF x_real = 'OTF'.
          d_desired_type = 'PDF'.
        ELSE.
          d_desired_type = x_real.
        ENDIF.
      ELSE.
        IF ( d_desired_type = 'PDF' OR
             d_desired_type = 'OTF' ) AND
           ( x_real = 'OTF' OR
             x_real = 'PDF' ).
          d_desired_type = 'PDF'.
        ELSE.
          IF d_desired_type <> x_real.
            RAISE type_no_match.
          ENDIF.
        ENDIF.
        IF ( d_desired_type = 'ALI' OR
             d_desired_type = 'RAW' ) AND
             x_real = 'OTF'.
          RAISE type_no_match.
        ENDIF.
      ENDIF.
    * Check if ABAP-LIST and not SapScript...
      IF d_desired_type = 'ALI' OR
         d_desired_type = 'RAW'.
        t_soli[] = t_otf[].
        EXIT.
      ENDIF.
    * Load OTF data gotten from spool...
      LOOP AT t_otf.
        t_itcoo = t_otf.
        APPEND t_itcoo.
    *   if Vendor P/O (SapScript = Z_MEDRUCK) then
    *      trap INDEX for "Terms & Conditions" on BACK...
        IF t_itcoo-tdprintcom =  'IN' AND
           t_itcoo-tdprintpar =  '01EZ_MEDRUCK       BACK'.
          x_idx_b = sy-tabix.
        ENDIF.
        IF t_itcoo-tdprintcom =  'IN' AND
           t_itcoo-tdprintpar =  '01EZ_MEDRUCK       NEXT'.
          x_idx_e = ( sy-tabix - 1 ).
        ENDIF.
      ENDLOOP.
    * Drop from table if INDEX'S are set (see above)...
      IF ( x_idx_b > 0 AND
         ( x_idx_e > x_idx_b ) ) .
        DELETE t_itcoo FROM x_idx_b
                     TO x_idx_e.
      ENDIF.
      PERFORM convert_otf_2_pdf.
    ENDFORM.                               " convert_otf_2_pdf_sx
    *&      Form  CONVERSION_OF_SIZE                                       *
    * *"Converting the file to get a 255 char single line internal table   *
    * The PDF file that is generated out of the above function module     *
    * cannot be transported as it needs to be of 255 chars. Hence         *
    * converting the file to get a 255 char single line,internal table.   *
    FORM conversion_of_size .
    "Declaring Local Constants............................................
      CONSTANTS:
         cnv_hexconst_zero TYPE x VALUE '00'.
    * Internal table to hold 255 Char's Single Line.                      *
      DATA:
        lv_big_lines(268) TYPE c
                          OCCURS 0 WITH HEADER LINE.
    *"Local Work Variables.................................................
      DATA:
        lfl_flag          TYPE c,
        lv_left_t(268)    TYPE c,
        lv_left_i         TYPE i,
        tv_left_i         TYPE i,
        lv_curr_i         TYPE i.
      FIELD-SYMBOLS: <f>.
    * Get the lines into a table of 268 char as the first step to put it in
    * the pdf file of 255 chars
      CLEAR lfl_flag.
      LOOP AT t_line.
        IF lfl_flag EQ ' '.
          CLEAR lv_big_lines.
          ASSIGN lv_big_lines(134) TO <f>.
          <f> = t_line.
          lfl_flag = 'X'.
        ELSE.
          lv_big_lines+134 = t_line.
          APPEND lv_big_lines.
          CLEAR: lfl_flag.
        ENDIF.                             " If lfl_flag = ''..
      ENDLOOP.                             " Loop at t_pdf
      IF lfl_flag EQ 'X'.
        APPEND lv_big_lines.
      ENDIF.                               " If lflf_flag eq 'X'..
    * Next fill it into a 255 char table
      CLEAR: lv_left_t, lv_left_i, tv_left_i.
      lv_curr_i = 255.
      LOOP AT lv_big_lines.
        IF lv_left_i NE 0.
          IF lv_curr_i NE 0.
            wa_objcont(lv_left_i)           = lv_left_t(lv_left_i).
            wa_objcont+lv_left_i(lv_curr_i) = lv_big_lines(lv_curr_i).
          ELSE.
            wa_objcont = lv_left_t(lv_left_i).
          ENDIF.                           " IF lv_curr_i NE 0
        ELSE.
          wa_objcont = lv_big_lines(lv_curr_i).
        ENDIF.                             " IF lv_left_i NE 0
        APPEND wa_objcont TO t_objcont.
        tv_left_i = 268 - lv_curr_i.
        IF tv_left_i > 255.
          wa_objcont = lv_big_lines+lv_curr_i(255).
          APPEND wa_objcont TO t_objcont.
          lv_left_i = tv_left_i - 255.
          tv_left_i = 255 + lv_curr_i.
          lv_curr_i = 255 - lv_left_i.
          lv_left_t = lv_big_lines+tv_left_i.
        ELSE.
          lv_left_t = lv_big_lines+lv_curr_i.
          lv_left_i = 268 - lv_curr_i.
          lv_curr_i = 255 - lv_left_i.
        ENDIF.                             " IF tv_left_i > 255
      ENDLOOP.                             " LOOP AT lv_big_lines.
      CLEAR wa_objcont .
      ASSIGN wa_objcont(lv_left_i) TO <f>.
      <f> = lv_left_t(lv_left_i).
      APPEND wa_objcont TO t_objcont.
        h_transf_type = 'X'.                 " Transfer type BINARY...
      IF NOT t_objcont[] IS INITIAL.
        t_soli[]     = t_objcont[].        " SapScript doc to Objects...
      ENDIF.
    regards
    twinkal

  • Workflow Step 'In Process'- Send mail with PDF attachment

    Hi,
    have to send mail with PDF attachment.
    I have written a function module with following steps,
    1. Convert SPOOL number to PDF using Function Module 'CONVERT_OTFSPOOLJOB_2_PDF'.
    2. Send mail with PDF attachment using Function Module 'SO_DOCUMENT_SEND_API1'.
    The Function Module is giving required output when tested and called in the report(Background Job).
    When I call this Function Module from Method-> Workflow Task the Workflow steps status is 'In Process' and not ending.
    Could you please help me on this??

    Hi shafath,
    When you try to send mail,  You need to call the function FP_JOB_OPEN before calling the function module to generate the pdf. ( /1B****)  . Is it missing in your code?

  • Error while sending a mail with pdf attachment

    Hai
    I am sending mail with an attachment of PDF document. While sending I am getting
    javax.activation.UnsupportedDataTypeException: application/pdf
    This is my code
    public static void setByteArrayAsAttachment(Message msg, byte[] attach)
    throws MessagingException {
    MimeBodyPart p1 = new MimeBodyPart();
    ByteArrayDataSource byteStr = new ByteArrayDataSource(attach,"application/pdf");
    p1.setContent(byteStr,"application/pdf");
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(p1);
    msg.setContent(mp);
    Can one one help me on this...
    Thanks
    Jithesh PM

    Change
    p1.setContent(byteStr,"application/pdf");
    to
    p1.setDataHandler(new DataHandler(byteStr));

  • Error occured when sending mail with PDF attachment

    Dear Experts
    When i trigger email through SMTP server with PDF attachment using application server 10g , i got following error :
    REP-50159: Executed successfully but there were some errors when distribute the output
    i am using web.show_document utility
    str1:='http://erp.ruchi.com:7777/reports/rwservlet?destype=mail'||'&desname='||c1rec.hist_email||'&from=[email protected]'||'&subject=Your Payslip for Month '||to_char(c1rec.tran_month,'Mon-YYYY')||'&desformat=PDF&server=rep_erp_bi&report=/asdeploy/webutil/pay/reports/payslip.rdf&userid=qwqwqw/aasasas@DIAMOND'||'&COMPANY='||:parameter.para_comp_code||'&LOCATION='||:parameter.para_loc_code||'&MONTH='||to_char(:sdate,'MM/YYYY')||'&ECODE='||c1rec.tran_ecode;
    WEB.SHOW_DOCUMENT(str1,'_SELF');
    previously i had successfully using this utility but now i am facing above error
    Pl suggest
    regards
    shailesh

    Dear Experts
    I already configured application server configuration file with specifying SMTP mail server IP in pluginParam parameter
    <pluginParam name="mailServer">202.157.161.76</pluginParam>
    <property name="enableSSL" value="no"/>
    <property name="mailUserName" value="%[email protected]%"/>
    <property name="mailPassword" value="%soyacl#123%"/>
    what is the issue
    Pl clarify
    Please reply it's urgent

  • Problem in sending mail with PDF attachment

    Hi all,
    Kindly check this code..
    I neeed to send the smartform as a PDF attachment..
    PDF generated form of smartform is generated successfully..
    <b>but PDF  going as attachment is showing errors in opening</b> .
    Please help me to solve this issue as soon as possible
          DESCRIBE TABLE objtxt LINES tab_lines.
          READ TABLE objtxt INDEX tab_lines.
          doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
         doc_chng-doc_size = tab_lines * 255.
    Creation of the entry for the compressed document
          CLEAR objpack-transf_bin.
          objpack-head_start = 1.
          objpack-head_num = 0.
          objpack-body_start = 1.
          objpack-body_num = tab_lines.
          objpack-doc_type = 'RAW'.
          APPEND objpack.
    Creation of the document attachment
          DESCRIBE TABLE objbin LINES tab_lines.
    Creation of the entry for the compressed document
          CLEAR objpack-transf_bin.
          objpack-transf_bin = 'X'.
          objpack-head_start = 1.
          objpack-head_num = 0.
          objpack-body_start = 1.
          READ TABLE objbin INDEX tab_lines.
          objpack-doc_size =  tab_lines * 255 .
          objpack-body_num = tab_lines.
          objpack-doc_type = 'PDF'.
          objpack-obj_name = 'SMART'.
          objpack-obj_descr = 'test'.
          APPEND objpack.
    Completing the recipient list
    target recipent
          CLEAR reclist.
          reclist-receiver = '[email protected]'.
          reclist-express  = 'X'.
          reclist-rec_type = 'U'.
          APPEND reclist.
    Sending the document
          CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
            EXPORTING
              document_data              = doc_chng
              put_in_outbox              = 'X'
            TABLES
              packing_list               = objpack
              object_header              = objhead
              contents_bin               = objbin
              contents_txt               = objtxt
              receivers                  = reclist
            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                     = 99.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
    Regards,
    ajith

    Hello Ajith,
    Use this Code.
    Internal Table declarations
    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
    i_tline TYPE TABLE OF tline WITH HEADER LINE,
    i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
    i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    wa_objhead TYPE soli_tab,
    w_ctrlop TYPE ssfctrlop,
    w_compop TYPE ssfcompop,
    w_return TYPE ssfcrescl,
    wa_doc_chng typE sodocchgi1,
    w_data TYPE sodocchgi1,
    wa_buffer TYPE string,"To convert from 132 to 255
    Variables declarations
    v_form_name TYPE rs38l_fnam,
    v_len_in LIKE sood-objlen,
    v_len_out LIKE sood-objlen,
    v_len_outn TYPE i,
    v_lines_txt TYPE i,
    v_lines_bin TYPE i.
    call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
    formname = 'ZZZ_TEST1'
    importing
    fm_name = v_form_name
    exceptions
    no_form = 1
    no_function_module = 2
    others = 3.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    w_ctrlop-getotf = 'X'.
    w_ctrlop-no_dialog = 'X'.
    w_compop-tdnoprev = 'X'.
    CALL FUNCTION v_form_name
    EXPORTING
    control_parameters = w_ctrlop
    output_options = w_compop
    user_settings = 'X'
    IMPORTING
    job_output_info = w_return
    EXCEPTIONS
    formatting_error = 1
    internal_error = 2
    send_error = 3
    user_canceled = 4
    OTHERS = 5.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    i_otf[] = w_return-otfdata[].
    call function 'CONVERT_OTF'
    EXPORTING
    format = 'PDF'
    max_linewidth = 132
    IMPORTING
    bin_filesize = v_len_in
    TABLES
    otf = i_otf
    lines = i_tline
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    others = 4.
    Fehlerhandling
    if sy-subrc <> 0.
    endif.
    loop at i_tline.
    translate i_tline using '~'.
    concatenate wa_buffer i_tline into wa_buffer.
    endloop.
    translate wa_buffer using '~'.
    do.
    i_record = wa_buffer.
    append i_record.
    shift wa_buffer left by 255 places.
    if wa_buffer is initial.
    exit.
    endif.
    enddo.
    Attachment
    refresh:
    i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
    clear wa_objhead.
    i_objbin[] = i_record[].
    Create Message Body
    Title and Description
    i_objtxt = 'test with pdf-Attachment!'.
    append i_objtxt.
    describe table i_objtxt lines v_lines_txt.
    read table i_objtxt index v_lines_txt.
    wa_doc_chng-obj_name = 'smartform'.
    wa_doc_chng-expiry_dat = sy-datum + 10.
    wa_doc_chng-obj_descr = 'smartform'.
    wa_doc_chng-sensitivty = 'F'.
    wa_doc_chng-doc_size = v_lines_txt * 255.
    Main Text
    wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
    clear i_objpack-transf_bin.
    i_objpack-head_start = 1.
    i_objpack-head_num = 0.
    i_objpack-body_start = 1.
    i_objpack-body_num = v_lines_txt.
    i_objpack-doc_type = 'RAW'.
    append i_objpack.
    Attachment
    (pdf-Attachment)
    i_objpack-transf_bin = 'X'.
    i_objpack-head_start = 1.
    i_objpack-head_num = 0.
    i_objpack-body_start = 1.
    Länge des Attachment ermitteln
    describe table i_objbin lines v_lines_bin.
    read table i_objbin index v_lines_bin.
    i_objpack-doc_size = v_lines_bin * 255 .
    i_objpack-body_num = v_lines_bin.
    i_objpack-doc_type = 'PDF'.
    i_objpack-obj_name = 'smart'.
    i_objpack-obj_descr = 'test'.
    append i_objpack.
    clear i_reclist.
    i_reclist-receiver = '[email protected]'.
    i_reclist-rec_type = 'U'.
    append i_reclist.
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = wa_doc_chng
    put_in_outbox = 'X'
    TABLES
    packing_list = i_objpack
    object_header = wa_objhead
    CONTENTS_BIN = i_objbin
    contents_txt = i_objtxt
    receivers = i_reclist
    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.
    if helped reward points
    Vasanth

  • Error while sending mail with pdf attachment

    Dear All,
    I am sending mail to outlook Internet address, with PDF attachment, if i have the some text in the mail along with the attachment,
    then the PDF attachment file is not opeining, throws file corrupted error.
    If i don't have the text for mail body, and send only attachment then the PDF attachments working fine.
    Please help.
    regards,
    Kumar.

    Hi Kumar,
    If you are using the th FM "SO_NEW_DOCUMENT_ATT_SEND_API1" to send the PDF data(As an attachment) to an internet address, try prepare an internal table with the text you want to mention in your mail. This table needs to be passed to the
    'contents_txt' of this function module.  You can check your mail in SOST transaction and in DOC Content section.
      Ex:  wa_objtxt           = 'Regards'.
             APPEND wa_objtxt TO t_objtxt.
    I am sure that you won't get any problem if you follow the procedure mentioned above.
    Thank You,
    Regards,
    Naresh.

  • Problem for Mail with PDF attachment

    Hello all,
    I have a problem regarding sending mail with a PDF attachment from SAP. The attachment contains Payslip of employee that is being generated from a Submit program of the respective HRFORM. I have used the Submit program within a JOB and the spool request generated. From the spool request i am extracting the pages using FM RSPO_GET_PAGES_SPOOLJOB.
    Now to convert the spool job to PDF am using FM CONVERT_OTFSPOOLJOB_2_PDF.  And after the job is being finished, am deleting both the JOB and SPOOL.
    To change the output of the FM CONVERT_OTFSPOOLJOB_2_PDF, into attachment with line width of 255 am using FM SX_TABLE_LINE_WIDTH_CHANGE. Then after filling all the required parameters for FM SO_DOCUMENT_SEND_API1, am sending the mail with the attachment. I have kept the format as PDF.
    But the problem here is, the attachment is going as .DAT file and not as .PDF file!!!
    Please help to resolve this issue.
    with regards,
    Koushik.

    Hello,
    Instead of using SO* APIs to send mail you should use the BCS classes. Anyway there is a sample program BCS_EXAMPLE_8 which is very similar to your requirement
    Cheers,
    Suhas
    PS: The sample program BCS_EXAMPLE_6 has got more to do with PDF forms as is your case

  • Sending an e-mail with pdf attachment and logo as a signature

    Hi,
    My task is to send an email with pdf attachement. And an image file need to be added as a signature. Is it possible, if so, can anyone please guide me?
    Thanking you.
    Kumar.

    Hi
    I'm having the same issue, except my application actually sends the email but the attachment is 0 octet and it doesn't even give me an error... Any chance you found a solution for this and could share it ?
    Thanks

  • Reg sending Mail with PDF attachment

    Hi All,
              Am converting smartforms(Purchase Order Me23N) to pdf then am attaching pdf in mail,mail is going with attachment to specific id but when i try to open PDF file am getting an Error PDF File is Corrupted.
    Am using these FM :CONVERT_OTF(To convert from smartforms to PDF) , SO_NEW_DOCUMENT_ATT_SEND_API1(For pdf attachment).
    Please Help with ur suggestions.
    Regards,
    vinoth.

    Please post the same in Workflow forum for more inputs. are you using interactive forms.

  • Sending Mail  with PDF attachment

    Hi Guys ,
    if i am getting the script output data in OTF foramt ( by selecting the ITCPO-TDGETOTF = 'X' , which Doc_type i have to use to send  it as a PDF attachement.
    i am using FM
    SO_NEW_DOCUMENT_ATT_SEND_API1
    to send message from sap to Xchange server .
    Regards
    Prabhu

    Refer to this code, this is working fine in my 4.6c system:
    REPORT YBALTEST.
    DATA: gd_cnt TYPE i,
    gd_sent_all(1) TYPE c,
    gd_doc_data LIKE sodocchgi1,
    gd_error TYPE sy-subrc.
    DATA OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    DATA: it_message LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0,
    row(255).
    DATA: END OF it_pdf_output.
    START-OF-SELECTION.
    perform send_email_message .
    *& Form SEND_EMAIL_MESSAGE
    Send email message
    FORM send_email_message.
    DATA: tab_lines LIKE SY-TABIX.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'C:\test.pdf'
    filetype = 'BIN'
    TABLES
    data_tab = it_pdf_output .
    Populate the subject/generic message attributes
    concatenate 'Attached is the '
    ' are waiting for.' into it_message.
    append it_message.
    DESCRIBE TABLE it_message LINES tab_lines.
    READ TABLE it_message INDEX tab_lines.
    gd_doc_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_message ).
    gd_doc_data-obj_langu = sy-langu.
    gd_doc_data-obj_name = 'SENDFILE'.
    gd_doc_data-obj_descr = 'Attachement'.
    gd_doc_data-sensitivty = 'O'.
    describe table it_pdf_output lines tab_lines.
    Describe the body of the message
    CLEAR it_packing_list-transf_bin.
    it_packing_list-head_start = 1.
    it_packing_list-head_num = 0.
    it_packing_list-body_start = 1.
    it_packing_list-doc_type = 'RAW'.
    it_packing_list-body_num = tab_lines.
    APPEND it_packing_list.
    loop at it_pdf_output.
    move it_pdf_output-row to objbin-line.
    append objbin.
    endloop.
    describe table objbin lines tab_lines.
    CLEAR it_packing_list.
    it_packing_list-transf_bin = 'X'.
    it_packing_list-head_start = 1.
    it_packing_list-head_num = 1.
    it_packing_list-body_start = 1.
    it_packing_list-doc_type = 'PDF'.
    it_packing_list-body_num = tab_lines.
    it_packing_list-doc_size = tab_lines * 255.
    it_packing_list-OBJ_DESCR = ' object '.
    *it_packing_list-obj_name = 'MAIL'.
    APPEND it_packing_list.
    it_receivers-receiver = '[email protected]'.
    it_receivers-rec_type = 'U'.
    it_receivers-com_type = 'INT'.
    APPEND it_receivers .
    Call the FM to post the message to SAPMAIL
    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 = objbin
    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.
    ENDFORM. " SEND_EMAIL_MESSAGE
    Cheers

  • How to send mail with pdf attachment.

    hello,
    I want to know if I can send a pdf attachment via mail. My PDF file is somewhere in the server and its content doesn't need to be changed by the program. the program just needs to find the pdf in server, then it will just send pdf file as attachment to the mail. is it possible ? thanks in advance.

    Hi Friend,
    You can easily send the document by email as follows :
    REPORT ZSENDEXTERNAL.
    DATA: OBJPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: OBJHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: OBJBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: OBJTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: RECLIST   LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    DATA: DOC_CHNG  LIKE SODOCCHGI1.
    DATA: TAB_LINES LIKE SY-TABIX.
    Creation of the document to be sent
    File Name
    DOC_CHNG-OBJ_NAME = 'SENDFILE'.
    Mail Subject
    DOC_CHNG-OBJ_DESCR = 'Send External Mail'.
    Mail Contents
    OBJTXT = 'Minimum bid : $250000'.
    APPEND OBJTXT.
    OBJTXT = 'A representation of the pictures up for auction'.
    APPEND OBJTXT.
    OBJTXT = 'was included as attachment.'.
    APPEND OBJTXT.
    DESCRIBE TABLE OBJTXT LINES TAB_LINES.
    READ TABLE OBJTXT INDEX TAB_LINES.
    DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creation of the entry for the compressed document
    CLEAR OBJPACK-TRANSF_BIN.
    OBJPACK-HEAD_START = 1.
    OBJPACK-HEAD_NUM = 0.
    OBJPACK-BODY_START = 1.
    OBJPACK-BODY_NUM = TAB_LINES.
    OBJPACK-DOC_TYPE = 'RAW'.
    APPEND OBJPACK.
    Creation of the document attachment
    (Assume that the data in OBJBIN is in BMP format)
    *OBJBIN = ' \O/ '. APPEND OBJBIN.
    *OBJBIN = ' | '. APPEND OBJBIN.
    *OBJBIN = ' / \ '. APPEND OBJBIN.
    *DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    *OBJHEAD = 'PICTURE.BMP'.
    *APPEND OBJHEAD.
    Creation of the entry for the compressed attachment
    *OBJPACK-TRANSF_BIN = 'X'.
    *OBJPACK-HEAD_START = 1.
    *OBJPACK-HEAD_NUM = 1.
    *OBJPACK-BODY_START = 1.
    *OBJPACK-BODY_NUM = TAB_LINES.
    *OBJPACK-DOC_TYPE = 'PDF'.
    *OBJPACK-OBJ_NAME = 'PICTURE'.
    *OBJPACK-OBJ_DESCR = 'Representation of object 138'.
    *OBJPACK-DOC_SIZE = TAB_LINES * 255.
    *APPEND OBJPACK.
    Completing the recipient list
    RECLIST-RECEIVER = <External Email id >.
    RECLIST-REC_TYPE = 'U'.
    APPEND RECLIST.
    *RECLIST-RECEIVER = 'SAPUSERNAME'.
    *RECLIST-REC_TYPE = 'P'.
    *APPEND RECLIST.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
       DOCUMENT_DATA = DOC_CHNG
       PUT_IN_OUTBOX = 'X'
    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.
    CASE SY-SUBRC.
       WHEN 0.
       WRITE: / 'Result of the send process:'.
    LOOP AT RECLIST.
       WRITE: / RECLIST-RECEIVER(48), ':'.
       IF RECLIST-RETRN_CODE = 0.
          WRITE 'The document was sent'.
       ELSE.
          WRITE 'The document could not be sent'.
    ENDIF.
    ENDLOOP.
    WHEN 1.
       WRITE: / 'No authorization for sending to the specified number',
                'of recipients'.
    WHEN 2.
       WRITE: / 'Document could not be sent to any recipient'.
    WHEN 4.
       WRITE: / 'No send authorization'.
    WHEN OTHERS.
       WRITE: / 'Error occurred while sending'.
    ENDCASE.
    Regards
    Dhirendra Pandit

  • Receive mail with PDF attachment into XI and send to ABAP proxy

    Hi,
    I have a scenario where I need to receive a mail into XI that has a PDF attachment. This attachment needs to be retained as ultimately I need to send the message into CRM via an ABAP proxy and read the attachment and load against a business partner.
    However, as I am only on SP13 I do not have the parameters such "Keep Attachments" available to use.
    So I have two questions:
    1. How do I receive the mail into XI with the PDF attachment ?
    2. How do I read the attachment in an ABAP proxy ?
    Any guidance in either question would be appreciated.
    Cheers
    Colin.

    hi,
    you say that there's no keep attachment
    indicator but does the XI store the attachment or not?
    maybe it stores all attachmens
    (I work with sp16 and I don't remember how it worked with sp13)
    but try maybe it accepts attachments by default
    then it would be quite easy
    if you use then use the attachement in abap proxy
    (like I said you won't have to use any java)
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Sapscript/Smartform via mail with PDF attachment: logo is missing

    Hi all
    I'm implementing my function to send Sapscript/smartform via mail.
    I need to do it because when a message needs to be sent, I have to insert the message as attachment but also to add a text in the body mail.
    So I've just created a simple sapscript having a logo (as graphic) and a little text.
    I use the fm CONVERT_OTF to convert the OTF to PDF format and the following code to increase the pdf string from 132 to 255 char:
    LOOP AT t_pdf.
          TRANSLATE t_pdf USING ' ~'.
          CONCATENATE l_buffer t_pdf INTO l_buffer.
        ENDLOOP.
        TRANSLATE l_buffer USING '~ '.
        DO.
          MOVE l_buffer TO l_attachment.
          APPEND l_attachment TO x_attachment.
          SHIFT l_buffer LEFT BY 255 PLACES.
          IF l_buffer IS INITIAL.
            EXIT.
          ENDIF.
        ENDDO.
    All seem to work fine, but as soon as I open the pdf file attached to the mail I can't see the logo
    So after calling fm CONVERT_OTF, I've created a pdf file by method GUI_DOWNLOAD, and then upload this file (by GUI_UPLOAD) into internal table for attachment and send the mail.
    Now really all work very fine, becaus I can see the logo
    Of course I don't want to dowload the file before sending a mail, but I need to send my print directly as pdf attachment
    The two ways seem to be equal, they use the same print and the same functions, only the way to upload the internal table for attachment is different:
    1) tha abap code above to expand the line from 132 to 255
    2) the method GUI_UPLOAD
    So something seems to be wrong in the first way because ithe logo is missing in the pdf attachment generated for the mail
    Max

    Hi
    I'm not working on unicode system, anyway I didn't see that parameter BIN_FILE, so I didn't use it
    I've read the note 1324547 and I've done just as it explaines: now works fine
    I don't know why it doesn't work with old manner (i.e data is treated as character-type), but it worls with the new one (If the data is treated as xstring-type)
    I can only suppose the data are corrupted while being elaborated for expand to 255 char....but I don't why
    Anyway your suggestion works for me
    Thank
    Max

  • Problem with package that create mail with PDF attachment

    Hola,
    I've this problem when I use the Oracle Package called "demo_mail",
    that I have download from this forum en september.
    The code of the Package, I post bottom, now I
    write the records of the Package,
    that I believe is the core of the problem:
    demo_mail.begin_attachment( conn => conn,
    mime_type => 'application/pdf',
    inline => TRUE, filename => ''|| VC_NOMEFILE ||'',
    transfer_enc => 'base64');
    The mime_type is correct?
    Why when I open the attachment of the mail, it say me that file type
    is not correct or the file has been damneged? I need help!
    Thank's
    *********************************************************The steps that I've done:
    1. PACKAGE demo_mail
    2. PACKAGE BODY demo_mail
    3. procedure P_SPEDMAILSERVATTA (that call package) this
    Cannot write the code, because this the result. :(((
    thank's
    CREATE OR REPLACE PACKAGE demo_mail IS
    -- Customize the SMTP host, port and your domain name below.
    smtp_host VARCHAR2(256) := 'XXX.YYYY.IT';
    smtp_port PLS_INTEGER := 25;
    smtp_domain VARCHAR2(256) := 'YYYY.it';
    -- Customize the signature that will appear in the email's MIME header.
    -- Useful for versioning.
    MAILER_ID CONSTANT VARCHAR2(256) := 'Mailer by Oracle UTL_SMTP';
    --------------------- End Customizable Section ---------------------
    -- A unique string that demarcates boundaries of parts in a multi-part email
    -- The string should not appear inside the body of any part of the email.
    -- Customize this if needed or generate this randomly dynamically.
    BOUNDARY CONSTANT VARCHAR2(256) := '-----7D81B75CCC90D2974F7A1CBD';
    FIRST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || utl_tcp.CRLF;
    LAST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || '--' ||
    utl_tcp.CRLF;
    -- A MIME type that denotes multi-part email (MIME) messages.
    MULTIPART_MIME_TYPE CONSTANT VARCHAR2(256) := 'multipart/mixed; boundary="'||
    BOUNDARY || '"';
    MAX_BASE64_LINE_WIDTH CONSTANT PLS_INTEGER := 76 / 4 * 3;
    -- A simple email API for sending email in plain text in a single call.
    -- The format of an email address is one of these:
    -- someone@some-domain
    -- "Someone at some domain" <someone@some-domain>
    -- Someone at some domain <someone@some-domain>
    -- The recipients is a list of email addresses separated by
    -- either a "," or a ";"
    PROCEDURE mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              message IN VARCHAR2);
    -- Extended email API to send email in HTML or plain text with no size limit.
    -- First, begin the email by begin_mail(). Then, call write_text() repeatedly
    -- to send email in ASCII piece-by-piece. Or, call write_mb_text() to send
    -- email in non-ASCII or multi-byte character set. End the email with
    -- end_mail().
    FUNCTION begin_mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              mime_type IN VARCHAR2 DEFAULT 'text/plain',
              priority IN PLS_INTEGER DEFAULT NULL)
              RETURN utl_smtp.connection;
    -- Write email body in ASCII
    PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
              message IN VARCHAR2);
    -- Write email body in non-ASCII (including multi-byte). The email body
    -- will be sent in the database character set.
    PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
                   message IN VARCHAR2);
    -- Write email body in binary
    PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
              message IN RAW);
    -- APIs to send email with attachments. Attachments are sent by sending
    -- emails in "multipart/mixed" MIME format. Specify that MIME format when
    -- beginning an email with begin_mail().
    -- Send a single text attachment.
    PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN VARCHAR2,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
              last IN BOOLEAN DEFAULT FALSE);
    -- Send a binary attachment. The attachment will be encoded in Base-64
    -- encoding format.
    PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN RAW,
                   mime_type IN VARCHAR2 DEFAULT 'application/octet',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   last IN BOOLEAN DEFAULT FALSE);
    -- Send an attachment with no size limit. First, begin the attachment
    -- with begin_attachment(). Then, call write_text repeatedly to send
    -- the attachment piece-by-piece. If the attachment is text-based but
    -- in non-ASCII or multi-byte character set, use write_mb_text() instead.
    -- To send binary attachment, the binary content should first be
    -- encoded in Base-64 encoding format using the demo package for 8i,
    -- or the native one in 9i. End the attachment with end_attachment.
    PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   transfer_enc IN VARCHAR2 DEFAULT NULL);
    -- End the attachment.
    PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   last IN BOOLEAN DEFAULT FALSE);
    -- End the email.
    PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection);
    -- Extended email API to send multiple emails in a session for better
    -- performance. First, begin an email session with begin_session.
    -- Then, begin each email with a session by calling begin_mail_in_session
    -- instead of begin_mail. End the email with end_mail_in_session instead
    -- of end_mail. End the email session by end_session.
    FUNCTION begin_session RETURN utl_smtp.connection;
    -- Begin an email in a session.
    PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
                        sender IN VARCHAR2,
                        recipients IN VARCHAR2,
                        subject IN VARCHAR2,
                        mime_type IN VARCHAR2 DEFAULT 'text/plain',
                        priority IN PLS_INTEGER DEFAULT NULL);
    -- End an email in a session.
    PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection);
    -- End an email session.
    PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection);
    END;
    CREATE OR REPLACE PACKAGE BODY demo_mail IS
    -- Return the next email address in the list of email addresses, separated
    -- by either a "," or a ";". The format of mailbox may be in one of these:
    -- someone@some-domain
    -- "Someone at some domain" <someone@some-domain>
    -- Someone at some domain <someone@some-domain>
    FUNCTION get_address(addr_list IN OUT VARCHAR2) RETURN VARCHAR2 IS
    addr VARCHAR2(256);
    i pls_integer;
    FUNCTION lookup_unquoted_char(str IN VARCHAR2,
                        chrs IN VARCHAR2) RETURN pls_integer AS
    c VARCHAR2(5);
    i pls_integer;
    len pls_integer;
    inside_quote BOOLEAN;
    BEGIN
    inside_quote := false;
    i := 1;
    len := length(str);
    WHILE (i <= len) LOOP
         c := substr(str, i, 1);
         IF (inside_quote) THEN
         IF (c = '"') THEN
         inside_quote := false;
         ELSIF (c = '\') THEN
         i := i + 1; -- Skip the quote character
         END IF;
         GOTO next_char;
         END IF;
         IF (c = '"') THEN
         inside_quote := true;
         GOTO next_char;
         END IF;
         IF (instr(chrs, c) >= 1) THEN
         RETURN i;
         END IF;
         <<next_char>>
         i := i + 1;
    END LOOP;
    RETURN 0;
    END;
    BEGIN
    addr_list := ltrim(addr_list);
    i := lookup_unquoted_char(addr_list, ',;');
    IF (i >= 1) THEN
    addr := substr(addr_list, 1, i - 1);
    addr_list := substr(addr_list, i + 1);
    ELSE
    addr := addr_list;
    addr_list := '';
    END IF;
    i := lookup_unquoted_char(addr, '<');
    IF (i >= 1) THEN
    addr := substr(addr, i + 1);
    i := instr(addr, '>');
    IF (i >= 1) THEN
         addr := substr(addr, 1, i - 1);
    END IF;
    END IF;
    RETURN addr;
    END;
    -- Write a MIME header
    PROCEDURE write_mime_header(conn IN OUT NOCOPY utl_smtp.connection,
                   name IN VARCHAR2,
                   value IN VARCHAR2) IS
    BEGIN
    utl_smtp.write_data(conn, name || ': ' || value || utl_tcp.CRLF);
    END;
    -- Mark a message-part boundary. Set <last> to TRUE for the last boundary.
    PROCEDURE write_boundary(conn IN OUT NOCOPY utl_smtp.connection,
                   last IN BOOLEAN DEFAULT FALSE) AS
    BEGIN
    IF (last) THEN
    utl_smtp.write_data(conn, LAST_BOUNDARY);
    ELSE
    utl_smtp.write_data(conn, FIRST_BOUNDARY);
    END IF;
    END;
    PROCEDURE mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              message IN VARCHAR2) IS
    conn utl_smtp.connection;
    BEGIN
    conn := begin_mail(sender, recipients, subject);
    write_text(conn, message);
    end_mail(conn);
    END;
    FUNCTION begin_mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              mime_type IN VARCHAR2 DEFAULT 'text/plain',
              priority IN PLS_INTEGER DEFAULT NULL)
              RETURN utl_smtp.connection IS
    conn utl_smtp.connection;
    BEGIN
    conn := begin_session;
    begin_mail_in_session(conn, sender, recipients, subject, mime_type,
    priority);
    RETURN conn;
    END;
    PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
              message IN VARCHAR2) IS
    BEGIN
    utl_smtp.write_data(conn, message);
    END;
    PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
                   message IN VARCHAR2) IS
    BEGIN
    utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(message));
    END;
    PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
              message IN RAW) IS
    BEGIN
    utl_smtp.write_raw_data(conn, message);
    END;
    PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN VARCHAR2,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
              last IN BOOLEAN DEFAULT FALSE) IS
    BEGIN
    begin_attachment(conn, mime_type, inline, filename);
    write_text(conn, data);
    end_attachment(conn, last);
    END;
    PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN RAW,
                   mime_type IN VARCHAR2 DEFAULT 'application/octet',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   last IN BOOLEAN DEFAULT FALSE) IS
    i PLS_INTEGER;
    len PLS_INTEGER;
    BEGIN
    begin_attachment(conn, mime_type, inline, filename, 'base64');
    -- Split the Base64-encoded attachment into multiple lines
    i := 1;
    len := utl_raw.length(data);
    WHILE (i < len) LOOP
    IF (i + MAX_BASE64_LINE_WIDTH < len) THEN
         -- After upgrade to Oracle 9i, replace demo_base64.encode with the
         -- native utl_encode.base64_encode for better performance:
         -- utl_smtp.write_raw_data(conn,
    -- utl_encode.base64_encode(utl_raw.substr(data, i,
         -- MAX_BASE64_LINE_WIDTH)));
         utl_smtp.write_raw_data(conn,
    utl_encode.base64_encode(utl_raw.substr(data, i,
         MAX_BASE64_LINE_WIDTH)));
    ELSE
         -- After upgrade to Oracle 9i, replace demo_base64.encode with the
         -- native utl_encode.base64_encode for better performance:
         -- utl_smtp.write_raw_data(conn,
         -- utl_encode.base64_encode(utl_raw.substr(data, i)));
         utl_smtp.write_raw_data(conn,
         utl_encode.base64_encode(utl_raw.substr(data, i)));
    END IF;
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    i := i + MAX_BASE64_LINE_WIDTH;
    END LOOP;
    end_attachment(conn, last);
    END;
    PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   transfer_enc IN VARCHAR2 DEFAULT NULL) IS
    BEGIN
    write_boundary(conn);
    write_mime_header(conn, 'Content-Type', mime_type);
    IF (filename IS NOT NULL) THEN
    IF (inline) THEN
         write_mime_header(conn, 'Content-Disposition',
         'inline; filename="'||filename||'"');
    ELSE
         write_mime_header(conn, 'Content-Disposition',
         'attachment; filename="'||filename||'"');
    END IF;
    END IF;
    IF (transfer_enc IS NOT NULL) THEN
    write_mime_header(conn, 'Content-Transfer-Encoding', transfer_enc);
    END IF;
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    END;
    PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   last IN BOOLEAN DEFAULT FALSE) IS
    BEGIN
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    IF (last) THEN
    write_boundary(conn, last);
    END IF;
    END;
    PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection) IS
    BEGIN
    end_mail_in_session(conn);
    end_session(conn);
    END;
    FUNCTION begin_session RETURN utl_smtp.connection IS
    conn utl_smtp.connection;
    BEGIN
    -- open SMTP connection
    conn := utl_smtp.open_connection(smtp_host, smtp_port);
    utl_smtp.helo(conn, smtp_domain);
    RETURN conn;
    END;
    PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
                        sender IN VARCHAR2,
                        recipients IN VARCHAR2,
                        subject IN VARCHAR2,
                        mime_type IN VARCHAR2 DEFAULT 'text/plain',
                        priority IN PLS_INTEGER DEFAULT NULL) IS
    my_recipients VARCHAR2(32767) := recipients;
    my_sender VARCHAR2(32767) := sender;
    BEGIN
    -- Specify sender's address (our server allows bogus address
    -- as long as it is a full email address ([email protected]).
    utl_smtp.mail(conn, get_address(my_sender));
    -- Specify recipient(s) of the email.
    WHILE (my_recipients IS NOT NULL) LOOP
    utl_smtp.rcpt(conn, get_address(my_recipients));
    END LOOP;
    -- Start body of email
    utl_smtp.open_data(conn);
    -- Set "From" MIME header
    write_mime_header(conn, 'From', sender);
    -- Set "To" MIME header
    write_mime_header(conn, 'To', recipients);
    -- Set "Subject" MIME header
    write_mime_header(conn, 'Subject', subject);
    -- Set "Content-Type" MIME header
    write_mime_header(conn, 'Content-Type', mime_type);
    -- Set "X-Mailer" MIME header
    write_mime_header(conn, 'X-Mailer', MAILER_ID);
    -- Set priority:
    -- High Normal Low
    -- 1 2 3 4 5
    IF (priority IS NOT NULL) THEN
    write_mime_header(conn, 'X-Priority', priority);
    END IF;
    -- Send an empty line to denotes end of MIME headers and
    -- beginning of message body.
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    IF (mime_type LIKE 'multipart/mixed%') THEN
    write_text(conn, 'This is a multi-part message in MIME format.' ||
         utl_tcp.crlf);
    END IF;
    END;
    PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection) IS
    BEGIN
    utl_smtp.close_data(conn);
    END;
    PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection) IS
    BEGIN
    utl_smtp.quit(conn);
    END;
    END;
    PROMPT     **********************************************************
    PROMPT     CREAZIONE PROCEDURA P_SPEDMAILSERVATTA
    PROMPT     **********************************************************
    create or replace procedure P_SPEDMAILSERVATTA( VC_DESCDENOAZIE IN VARCHAR2,
                                  VC_DESCINDIEMAI IN VARCHAR2,
                                  VC_NUMEBOLL     IN VARCHAR2,
                                  VC_PATHFILE     IN VARCHAR2,
                                  VC_NOMEFILE     IN VARCHAR2,
                                  VC_DESCINDIEMAIMITT IN VARCHAR2)
    IS
    conn utl_smtp.connection;
    req utl_http.req;
    resp utl_http.resp;
    data RAW(200);
    BEGIN
    conn := demo_mail.begin_mail(
    sender => 'SIAG srl <'|| VC_DESCINDIEMAIMITT ||'>',
    recipients => ''|| VC_DESCDENOAZIE ||' '||'<'|| VC_DESCINDIEMAI ||'>'||'',
    subject => 'Invio Bollettino n.'|| VC_NUMEBOLL ||'',
    mime_type => demo_mail.MULTIPART_MIME_TYPE);
    demo_mail.attach_text(
    conn => conn,
    data => 'Spett.le <b>'|| VC_DESCDENOAZIE ||'</b> <br> in allegato Le invio il Bollettino n. '|| VC_NUMEBOLL ||'.<br> <br> Distinti Saluti <br><br> <hr align="left" width="20%"> ',
    mime_type => 'text/html');
    demo_mail.begin_attachment(
    conn => conn,
    mime_type => 'application/pdf',
    inline => TRUE,
    filename => ''|| VC_NOMEFILE ||'',
    transfer_enc => 'base64');
    -- In writing Base-64 encoded text following the MIME format below,
    -- the MIME format requires that a long piece of data must be splitted
    -- into multiple lines and each line of encoded data cannot exceed
    -- 80 characters, including the new-line characters. Also, when
    -- splitting the original data into pieces, the length of each chunk
    -- of data before encoding must be a multiple of 3, except for the
    -- last chunk. The constant demo_mail.MAX_BASE64_LINE_WIDTH
    -- (76 / 4 * 3 = 57) is the maximum length (in bytes) of each chunk
    -- of data before encoding.
    req := utl_http.begin_request('http://localhost/'|| VC_PATHFILE ||'/'|| VC_NOMEFILE ||'');
    resp := utl_http.get_response(req);
    BEGIN
    LOOP
    utl_http.read_raw(resp, data, demo_mail.MAX_BASE64_LINE_WIDTH);
    demo_mail.write_raw(
    conn => conn,
    message => utl_encode.base64_encode(data));
    END LOOP;
    EXCEPTION
    WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
    END;
    demo_mail.end_attachment( conn => conn );
    demo_mail.end_mail( conn => conn );
    END;
    Message was edited by:
    mosquito70
    Message was edited by:
    mosquito70

    Hola, I've this problem when I use the Oracle Package called "demo_mail",
    that I have download from this forum en september.
    The code of the Package, I post bottom, now I
    write the records of the Package,
    that I believe is the core of the problem:
    demo_mail.begin_attachment( conn => conn,
    mime_type => 'application/pdf',
    inline => TRUE, filename => ''|| VC_NOMEFILE ||'',
    transfer_enc => 'base64');
    The mime_type is correct?
    Why when I open the attachment of the mail, it say me that file type
    is not correct or the file has been damneged? I need help!
    Thank's
    The steps that I've done:
    1. PACKAGE demo_mail
    2. PACKAGE BODY demo_mail
    3. procedure P_SPEDMAILSERVATTA (that call package)
    I cannot post the code :((

Maybe you are looking for

  • Select column 1 into two column from same table

    Dear Sir I have a data like studid makr tottal credit total average mark semester 251; 249.84; 41; 6.09; 1 106; 285.32; 42; 6.79; 1 285; 263.88; 38; 6.94; 1 251; 202.40; 28; 7.23; 2 106; 293.20; 39; 7.52; 2 285; 228.14; 39; 5.85; 2 I want to select a

  • Search in PDF

    Hi all, My Client requirement is to do a PDF search (non-english) in the Search module of his e-learning website. When i try to extract the contents of PDF for indexing, some of the characters are neglected during extraction (empty spaces in that are

  • Cell background image

    I would like to set a background image in a cell and have it not repeat. How do I do that?

  • Yosemite issues iPhoto images lost, bluetooth not syncing

    I uploaded Yosemite and then was instructed that iPhoto needed to be upgraded.  Did that and lost 50% of my albums. Also bluetooth is not syncing now and is breaking up. At the shop where I took the MacBook Pro, on returning, service person said many

  • 1.5.1/1.5/EA3/EA2/EA1: Another deadlock

    Hi, I was running a single query with bind variables by pushing the Run Query button, changing values between executions. Until sqldev locked up on pushing the button. Here's the stack dump: Full thread dump Java HotSpot(TM) Client VM (10.0-b19 mixed