Sending Mail with attachment and preserving the order of attachment

Hi Everyone!!!!!!
My requirement is to send Email with attachment in the same order as they were attached by Sender while composing the mail. I want to preserve order of attachment in the mail and when receiver open a mail, the attached files should be reflected in same order as it was on sender side. In my application,the documents being upload are already in my database. So, user just requires to mark the corresponding check box and enter the Sequence number for each attachment. When he clicks on "SEND" button, the Source file is first written from database to OS level and then files are attached from source available on OS . The attached file name could be anything. Based on the Sequence number file should be attached and send. My current code works fine,but problem it is that the Sequence number is not preserved in my attachment . However, when I traced the output of FOR Loop by inserting it in a table " temp_trace" I found that the Sequence is preserved in the order that I want. So, I think that uploaded files are written on the Operating system in same order but they are not attached in same order. Below is the sample code that is I am using to attach file in email. Here, the user_sequence is the sequence number entered by user.
for i in (select case when user_sequence is not null
then trim(to_char(user_sequence ,'09'))||'_'||file_name||'.pdf'
else ||'_'||file_name||'.pdf' end file_name ,
file_src,length(file_src) len,cd.doc_id,PRIORITY from
MIM_CLIENT_DOCS CD,(select DOC_ID ,user_sequence from table P_DOC_AND_user_sequence ) TEMP_TAB
WHERE CD.DOC_ID = TEMP_TAB.DOC_ID order by case when user_sequence is null then 1 else 0 end, file_name)
loop
insert into temp_trace values(i.file_name);
L_OUT := UTL_FILE.FOPEN(v_oracle_dir,i.file_name,'wb',32760);
end loop;
I want my output as
1_first attachment.txt
2_second_attachment.docx
3_abc.sql
_xxx.txt  ------------------ When sequence is not assigned by user That is null at last.
Unfortunately, I am not getting attachment in mail in this sequence. Can anyone give me suggestion.
Sorry for stuff essay and thanks in advance!!!!!!!!!!!

>
Please update your forum profile with a real handle instead of "974850".
My requirement is to send Email with attachment in the same order as they were attached by Sender while composing the mail. I want to preserve order of attachment in the mail and when receiver open a mail, the attached files should be reflected in same order as it was on sender side. In my application,the documents being upload are already in my database. So, user just requires to mark the corresponding check box and enter the Sequence number for each attachment. When he clicks on "SEND" button, the Source file is first written from database to OS level and then files are attached from source available on OS . The attached file name could be anything. Based on the Sequence number file should be attached and send. My current code works fine,but problem it is that the Sequence number is not preserved in my attachment . However, when I traced the output of FOR Loop by inserting it in a table " temp_trace" I found that the Sequence is preserved in the order that I want. So, I think that uploaded files are written on the Operating system in same order but they are not attached in same order. Below is the sample code that is I am using to attach file in email. Here, the user_sequence is the sequence number entered by user.Always post code using <tt>\...\</tt> tags as described in the FAQ.
for i in (select case when  user_sequence is not null
then trim(to_char(user_sequence ,'09'))||'_'||file_name||'.pdf'
else  ||'_'||file_name||'.pdf' end file_name ,
file_src,length(file_src) len,cd.doc_id,PRIORITY from
MIM_CLIENT_DOCS CD,(select DOC_ID ,user_sequence from table P_DOC_AND_user_sequence ) TEMP_TAB
WHERE CD.DOC_ID = TEMP_TAB.DOC_ID order by case when user_sequence is null then 1 else 0 end, file_name)                               
loop
insert into temp_trace values(i.file_name);
L_OUT := UTL_FILE.FOPEN(v_oracle_dir,i.file_name,'wb',32760);
end loop;I want my output as
1_first attachment.txt
2_second_attachment.docx
3_abc.sql
_xxx.txt  ------------------ When sequence is not assigned by user That is null at last.
Unfortunately, I am not getting attachment in mail in this sequence. Can anyone give me suggestion.I see no code that attaches anything to email messages. What code is used to do this? Why are the files being written to the file system?

Similar Messages

  • Sending mail with attachment fails on MAC Mail and WRP400.

    Sending mail with attachment fails on MAC Mail and WRP400.
    We have hundreds of WRP400 connected with Mac (Machintosh) computers. No special configurations are applied (no virtual server or DMZ). Web navigation, P2P programs and sending mail without attachment work right.
    The problem is the impossibility to send mails with medium or big size files attachment from MAC Mail.
    If we use Windows PCs or a different linksys routers (eg. WRT54G) the problem not happens.
    We have upgraded WRP400 firmware version from 1.00.06 to 2.00.05 but the result is the same. Sending mail with attachment using Mac fails.
    We tried to configure WRP400 with DMZ to a particular MAC. We tried to configure Virtual server on tcp 25 port of a MAC. The result is always the same.
    This is a WRP400 bug? Windows PCs work right. MAC and MAC mail works right with other linksys router.
    We need help. Thanks.

    The problem was fixed since beta firmware 2.00.11.
    I think that this issue was caused from a bug that decrease upload bitrate of WRP400 after some days of activity.
    See more details on Cisco forum under title "WRP400 stops responding after browsing certain websites".
    Thanks.

  • Send mail with attachment and more recipients

    Hi to all,
    I have this procedure :
    PROCEDURE SPEDISCI_MAIL
    Mittente IN VARCHAR2,
    Destinatario IN VARCHAR2,
    Oggetto IN VARCHAR2,
    Messaggio IN VARCHAR2
    IS
    mailhost VARCHAR2(40) := 'pippo.com';
    conn utl_smtp.connection;
    crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
    mesg VARCHAR2( 1000 );
    local_mittente VARCHAR2(2000) := mittente;
    BEGIN
    conn := utl_smtp.open_connection (mailhost,25);
    mesg:='Date:'||TO_CHAR(SYSDATE,'dd mon yy hh24:mi:ss')||crlf||
    'From:<'||mittente||'>'||crlf||
    'Subject:'||Oggetto||crlf||
    'To:'||destinatario||crlf||''
    ||crlf||messaggio;
    utl_smtp.helo(conn, mailhost);
    utl_smtp.mail(conn,local_mittente);
    utl_smtp.rcpt(conn,destinatario);
    utl_smtp.data(conn, mesg);
    utl_smtp.quit(conn);
    END;
    Can I send mail with attachment and more recipients?
    Thank you
    Silvia

    Consider using UTL_MAIL package:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_mail.htm
    (Note: it's not installed and configured by default, but the scripts are supplied with the Oracle database, see documentation for instructions)

  • Send mail with attachment from the uploaded file

    hi,
    From a form thread i got the following code to send mail with attachment with the file uploaded from the file upload ui element.
    public void onActionLoadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionLoadFile(ServerEvent)
         WDWebResourceType FileType = null;
         String FileName = new String();
              //get attribute info for context attribute 'FileUpload'
              IWDAttributeInfo attributeInfo =
                   wdContext.getNodeInfo().getAttribute(
                        IPrivateEmailView.IContextElement.FILE_UPLOAD);
              //get modifiable binary type from the attribute info,requires type cast.
              IWDModifiableBinaryType binaryType =
                   (IWDModifiableBinaryType) attributeInfo.getModifiableSimpleType();
              IPrivateEmailView.IContextElement element =
                   wdContext.currentContextElement();
              //if a file in the 'FileResource' attribute exists
              if (element.getFileUpload() != null) {
                   try {
                        String mimeType = binaryType.getMimeType().toString();
                        byte[] file = element.getFileUpload();
                        //get the size of the uploaded file
                        element.setFileSize(this.getFileSize(file));
                        //get the extension of the uploaded file
                        element.setFileExtension(binaryType.getMimeType().getFileExtension());
                        //NOTE: context attribute 'FileName' must not be set
                        //because the FileUpload-UI-element property 'fileName'
                        //is bound to it. Consequently the fileName is automatically
                        //written to the context after file upload.
                        //report success message
                        wdComponentAPI.getMessageManager().reportMessage(
                        IMessageEmailComp.SF_UPLOAD,
                             new Object[] { binaryType.getFileName()},
                             false);
                        FileType = binaryType.getMimeType();
                        FileName = binaryType.getFileName();
                   } catch (Exception e) {
                        throw new WDRuntimeException(e);
              //if no file in the 'FileResource' attribute exists
              else {
                   //report error message
                   IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
                   msgMgr.reportContextAttributeMessage(
                        element,
                        attributeInfo,
                        IMessageEmailComp.NO_FILE,
                        new Object[] { "" },
                        true);
              //clear the FileResource context value attribute
              //element.setFileUpload(null);
              String URL;
              URL = this.CreateAndGetPathFileUpload(
                                  wdContext.currentContextElement().getFileUpload(),
                                                      FileName);
    //          if (URL.length() == 1){
    //               //ERRORE
         wdContext.currentContextElement().setPATHFileUploaded(URL);
        //@@end
      public boolean send( java.lang.String subj, java.lang.String mess, java.lang.String dest, java.lang.String attach, java.lang.String FileName )
        //@@begin send()
         InitialContext ctx = null;
         Address[] address = null;
         Message msg = null;
         Session sess = null;
         MimeBodyPart bodyPart = null;
         Multipart mp = null;
         // "141.29.193.71" == milvl2ja.icn.siemens.it (SMTP di Siemens)
           try {
              Properties props = new Properties();
              props.put("domain","true");
              ctx = new InitialContext(props);
              sess = (Session) ctx.lookup("java:comp/env/mail/MailSession");
              msg = new MimeMessage(sess);
              IWDClientUser utente = WDClientUser.getCurrentUser();
              String senderEmail = utente.getSAPUser().getEmail();
              InternetAddress addressFrom = new InternetAddress(senderEmail);
              msg.setFrom(addressFrom);     
              String EmailDEST = dest;
              InternetAddress addressTo = new InternetAddress(EmailDEST);
              msg.setRecipient(Message.RecipientType.TO, addressTo);
              msg.setSubject(subj);
    //          if ((mess != null) && (mess.length()>0)) {
    //                 msg.setContent(mess, "text/plain");
    //            } else {
    //                 msg.setContent("", "text/plain");
              //Gestione ATTACHMENT...
              String attachedFileName = new String(wdContext.currentContextElement().getFileName());
              boolean hasAttachment = (attachedFileName != null) && (attachedFileName.length() > 0);
              boolean isMultiPart = (mess != null) && (mess.length() > 1);
              //adding an attachment makes the message multipart
                 if (isMultiPart || hasAttachment) {
                    mp = new MimeMultipart();
                    // add text parts
                      if (mess != null) {
                         for (int i = 0; i < mess.length(); i++) {
                           bodyPart = new MimeBodyPart();
                           bodyPart.setContent(mess,"text/plain");
                           mp.addBodyPart(bodyPart);
                    //attach the file to the message if needed
                    if (hasAttachment) {     // avoid the case with no text parts
                         bodyPart = new MimeBodyPart();
                           bodyPart.setContent("Allegato incluso nel messaggio.","text/plain");
                           mp.addBodyPart(bodyPart);
                           // the part with the file
                           FileDataSource fds = new FileDataSource(attach);
                           MimeBodyPart attachmentBodyPart = new MimeBodyPart();
                        attachmentBodyPart.setDataHandler(new DataHandler(fds));
                        //URL URLattachedFileName = new URL(attach);
                        //attachmentBodyPart.setDataHandler(new DataHandler(URLattachedFileName));
                           attachmentBodyPart.setFileName(FileName);
                           mp.addBodyPart(attachmentBodyPart);
                    msg.setContent(mp);
                 } else {
                    if ((mess != null) && (mess.length() > 0)) {
                         msg.setContent(mess, "text/plain");
                    } else {
                         msg.setContent("", "text/plain");
              //fine ATTACHMENT 
              msg.setSentDate(new GregorianCalendar().getTime());
              msg.saveChanges();
              address = msg.getAllRecipients();
              Transport.send(msg, address);
           } catch (Exception e) {
                 e.printStackTrace();
                 return false;
           return true;
        //@@end
    When i used the same code in my application i am gett ing error in many places..
    1)FileDataSource fds = new FileDataSource(<b>attach</b>);
    attach cannot be resolved
    2)attachmentBodyPart.setFileName(<b>FileName</b>);
    fliename cannot be resolved
    3)byte[] file = element.getFileUpload();
    type mismatch cannot convert sting to byte[]
    4)element.setFileSize(this.getFileSize(file));
    method getFileSize() is undefined
    5)element.setFileExtension(binaryType.getMimeType().getFileExtension());
    method getFilExtension() is undefined
    6)URL = this.CreateAndGetPathFileUpload(wdContext.currentContextElement().getFileUpload(),FileName);
    method CreateAndGetPathFileUpload() is undefined.
    7)wdContext.currentContextElement().setPATHFileUploaded(URL);
    from the above error i can understand that only i have got the part of the code.
    Please send me the complete coding.
    some method definitions are missing....
    Please help me to send the mail with attachment from the file uploaded from the file upload ui element.
    Thanks in advance,
    shami.

    hi,
    I got this from the following link
    Re: Attaching an excel file
    plz help me ...
    I am using 2004s with nwds 7.0.06.
    also tell me what should be the type of the context variable FileUpload
    Thanks in advance,
    shami.

  • Problem in sending  mail with attachment

    Hi All,
    I am using the function module <b>'SO_NEW_DOCUMENT_ATT_SEND_API1'</b> to send mail with attachment.
    the program executes properly and shows a message <b>'Document Sent'</b>. But neither the sent mail appears in <b>'SOST'</b> nor I get it on the specified email id.
    Below is my code:
    <b>***</b> As attachment I am sending resume whose contents are stored in table 'ZResume' corresponding to personnel no.(pernr) and serial No.(srno).
    <b>START OF PROGRAM</b>----
    REPORT  ZPTEST_SEND_MAIL_ATTATCHMENT.
    DATA : w_name TYPE sos04-l_adr_name.
    DATA: RESUME TYPE table of XSTRING with header line.
    START-OF-SELECTION.
    <b>* Data Declaration</b>
      DATA:
        l_datum(10),
        ls_docdata    TYPE sodocchgi1,
        lt_objpack    TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
        lt_objhead    TYPE TABLE OF solisti1   WITH HEADER LINE,
        lt_objtxt     TYPE TABLE OF solisti1   WITH HEADER LINE,
        lt_objbin     TYPE TABLE OF solisti1   WITH HEADER LINE,
        lt_reclist    TYPE TABLE OF somlreci1  WITH HEADER LINE,
        lt_listobject TYPE TABLE OF abaplist   WITH HEADER LINE,
        l_tab_lines TYPE i,
        l_att_type  LIKE soodk-objtp.
      WRITE sy-datum TO l_datum.
      SELECT SINGLE RESUME FROM ZRESUME INTO RESUME
          WHERE PERNR EQ '00001182'
          AND SRNO EQ '1'.
    APPEND RESUME.
    <b>* Because RESUME may be  of size RAW(1000)
    and objbin is of size CHAR(255) we make this table copy</b>
    CALL FUNCTION 'TABLE_COMPRESS'
        TABLES
          in             = resume
          out            = lt_objbin
        EXCEPTIONS
          compress_error = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
      Error in function module &1
        MESSAGE ID '61' TYPE 'E' NUMBER '731'
           WITH 'TABLE_COMPRESS'.
      ENDIF.
    <b>* Create the message and send the document.
    Create Message Body</b>
    <b>* Title and Description</b>
      ls_docdata-obj_name = 'Resume'.
      ls_docdata-obj_descr = 'Resume'.
    <b>* Main Text</b>
      lt_objtxt = 'Resume of the candidate' .
      APPEND lt_objtxt.
    <b>* Write Packing List (Main)</b>
      DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
      READ TABLE lt_objtxt INDEX l_tab_lines.
      ls_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
      CLEAR lt_objpack-transf_bin.
      lt_objpack-head_start = 1.
      lt_objpack-head_num = 0.
      lt_objpack-body_start = 1.
      lt_objpack-body_num = l_tab_lines.
      lt_objpack-doc_type = 'RAW'.
      APPEND lt_objpack.
    <b>* Create Message Attachment
    Write Packing List (Attachment)</b>
      l_att_type = 'ALI'.
      DESCRIBE TABLE lt_objbin LINES l_tab_lines.
      READ TABLE lt_objbin INDEX l_tab_lines.
      lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objbin ).
      lt_objpack-transf_bin = 'X'.
      lt_objpack-head_start = 1.
      lt_objpack-head_num = 0.
      lt_objpack-body_start = 1.
      lt_objpack-body_num = l_tab_lines.
      lt_objpack-doc_type = l_att_type.
      lt_objpack-obj_name = 'ATTACHMENT'.
      lt_objpack-obj_descr = 'Resume'.                  
      APPEND lt_objpack.
    <b>* Create receiver list</b>
        lt_reclist-receiver = '[email protected]'.
        lt_reclist-rec_type = 'U'.
        APPEND lt_reclist.
    <b>* Send Message</b>
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = ls_docdata
          put_in_outbox              = ''
        TABLES
          packing_list               = lt_objpack
          object_header              = lt_objhead
          contents_bin               = lt_objbin
          contents_txt               = lt_objtxt
          receivers                  = lt_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 sy-subrc = 0.
      Document sent
        MESSAGE ID 'SO' TYPE 'S' NUMBER '022'.
      ELSE.
      Document <&> could not be sent
        MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
           WITH ls_docdata-obj_name.
      ENDIF.
    <b>END OF PROGRAM</b>----
    Can anybody tell me where I am making mistake?
    Thanks in advance,
    Pragya

    Hi Pragya,
    Refer the code below. It's working fine and try to match up the things from your program.
    REPORT ZSAMPL_001 .
    INCLUDE ZINCLUDE_01.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    *file_open_error = 1
    *file_read_error = 2
    *no_batch = 3
    *gui_refuse_filetransfer = 4
    *invalid_type = 5
    *no_authority = 6
    *unknown_error = 7
    *bad_data_format = 8
    *header_not_allowed = 9
    *separator_not_allowed = 10
    *header_too_long = 11
    *unknown_dp_error = 12
    *access_denied = 13
    *dp_out_of_memory = 14
    *disk_full = 15
    *dp_timeout = 16
    *OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    ***INCLUDE ZINCLUDE_01 .
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    tables crmrfcpar.
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    data v_rfcdest LIKE crmrfcpar-rfcdest.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    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 = 8
    IF sy-subrc <> 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    FORM
    FORM ml_saveforbp USING jobname jobcount.
    Data
    *data : yhead like yhrt_bp_head.
    *DATA : ydocdata LIKE yhrt_bp_docdata,
    *yobjtxt LIKE yhrt_bp_objtxt OCCURS 0 WITH HEADER LINE,
    *yreclist LIKE yhrt_bp_reclist OCCURS 0 WITH HEADER LINE.
    *DATA : seqnr TYPE i.
    Head
    *yhead-jobname = jobname.
    *yhead-jobcount = jobcount..
    *MODIFY yhrt_bp_head FROM yhead.
    Doc Data
    *ydocdata-jobname = jobname.
    *ydocdata-jobcount = jobcount.
    *MOVE-CORRESPONDING docdata TO ydocdata.
    *MODIFY yhrt_bp_docdata FROM ydocdata.
    Objtxt
    *seqnr = 0.
    *LOOP AT objtxt.
    *seqnr = seqnr + 1.
    *yobjtxt-jobname = jobname.
    *yobjtxt-jobcount = jobcount.
    *yobjtxt-seqnr = seqnr.
    *MOVE-CORRESPONDING objtxt TO yobjtxt.
    *MODIFY yhrt_bp_objtxt FROM yobjtxt.
    *ENDLOOP.
    RecList
    *seqnr = 0.
    *LOOP AT reclist.
    *seqnr = seqnr + 1.
    *yreclist-jobname = jobname.
    *yreclist-jobcount = jobcount.
    *yreclist-seqnr = seqnr.
    *MOVE-CORRESPONDING reclist TO yreclist.
    *MODIFY yhrt_bp_reclist FROM yreclist.
    *ENDLOOP.
    ENDFORM. "ml_saveforbp
    FORM
    FORM ml_fetchfrombp USING jobname jobcount.
    *CLEAR docdata.
    *REFRESH objtxt.
    *REFRESH reclist.
    *SELECT SINGLE * FROM yhrt_bp_docdata
    *INTO corresponding fields of docdata
    *WHERE jobname = jobname
    *AND jobcount = jobcount.
    *SELECT * FROM yhrt_bp_objtxt
    *INTO corresponding fields of TABLE objtxt
    *WHERE jobname = jobname
    *AND jobcount = jobcount
    *ORDER BY seqnr.
    *SELECT * FROM yhrt_bp_reclist
    *INTO corresponding fields of TABLE reclist
    *WHERE jobname = jobname
    *AND jobcount = jobcount
    *ORDER BY seqnr.
    ENDFORM. "ml_fetchfrombp
    <b>Please reward points if it helps.</b>
    Regards,
    Amit Mishra

  • Convert Script output data to Text(.txt) file & send mail with attachment.

    Hi All,
    Requirement: I shulb be able to conver th Script output data to Text(.text) file & send a maill with attachment with this text file. Formant of text file should be like output of Print priview.
    Plese sugget with Function modules to cover as Text file.
    I am able to converting the Script output data to PDF and sending mail with attachment. So I don't want PDF file now.
    Thanks in advance.

    Hi, Thanks for responst.
    We can convert the Scirpt output to PDF file by using OTF function module and the PDF file looks like Print Privew output.
    Same like this I want Script out in NOTEPAD (.txt). Is that possible, Plz sugget with relavent Function Modules.
    Thanks.

  • Convert Screen(spool) to PDF file sending mail with attach file

    Hi :
    I'd like convert spool list to pdf and sending file...
    so, I read thread about spool convert to PDF before,
    and know how to convert Spool to PDF file and send mail with attach file.
    but I have a problem.
    my solution as:
    step 1. Call function: "CONVERT_ABAPSPOOLJOB_2_PDF"
    step 2. Call function: "SO_NEW_DOCUMENT_ATT_SEND_API1"
    then, I got a mail with attached PDF file, but the PDF file display limited 255 line.( SO_NEW_DOCUMENT_ATT_SEND_API1 limited)
    I want to showing word is wider that 255.
    and then I find a manual method as:
    After program finished.
    Function Menu -> system -> List -> Send
    use Prog: "Create Document and Send"
    I use this prog sending mail and attached file ,
    PDF file do <b>NOT</b> have 255 word limit !
    finally. my question is, If I want sending mail as Prog: "Create Document and Send", how to do?
    which Function I have to use?...
    Please help me, Thanks!

    Hi,
    Check this sample code of sending spool as attachment to an email address..
    Parameters.
    PARAMETERS: p_email(50) LOWER CASE.
    PARAMETERS: p_spool LIKE tsp01-rqident.
    Data declarations.
    DATA: plist         LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: document_data LIKE sodocchgi1.
    DATA: so_ali        LIKE soli OCCURS 100 WITH HEADER LINE.
    DATA: real_type     LIKE soodk-objtp.
    DATA: sp_lang       LIKE tst01-dlang.
    DATA: line_size     TYPE i VALUE 255.
    DATA: v_name        LIKE soextreci1-receiver.
    DATA rec_tab        LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    Get the spool data.
    CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
         EXPORTING
              rqident              = p_spool
              first_line           = 1
              last_line            = 0
              desired_type         = '   '
         IMPORTING
              real_type            = real_type
              sp_lang              = sp_lang
         TABLES
              buffer               = so_ali
         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.
      MESSAGE s208(00) WITH 'Error'.
      LEAVE LIST-PROCESSING.
    ENDIF.
    Prepare the data.
    plist-transf_bin = 'X'.
    plist-head_start = 0.
    plist-head_num = 0.
    plist-body_start = 0.
    plist-body_num = 0.
    plist-doc_type = 'RAW'.
    plist-obj_descr = 'Test ALV'.
    APPEND plist.
    plist-transf_bin = 'X'.
    plist-head_start = 0.
    plist-head_num = 0.
    plist-body_start = 1.
    DESCRIBE TABLE so_ali LINES plist-body_num.
    plist-doc_type = real_type.
    Get the size.
    READ TABLE so_ali INDEX plist-body_num.
    plist-doc_size = ( plist-body_num - 1 ) * line_size
                     + STRLEN( so_ali ).
    APPEND plist.
    Move the receiver address.
    MOVE: p_email  TO rec_tab-receiver,
          'U'      TO rec_tab-rec_type.
    APPEND rec_tab.
    IF NOT sp_lang IS INITIAL.
      document_data-obj_langu = sp_lang.
    ELSE.
      document_data-obj_langu = sy-langu.
    ENDIF.
    v_name = sy-uname.
    Send the email.
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
         EXPORTING
              document_data              = document_data
              sender_address             = v_name
              sender_address_type        = 'B'
         TABLES
              packing_list               = plist
              contents_bin               = so_ali
              receivers                  = rec_tab
         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 sy-subrc <> 0.
      MESSAGE e208(00) WITH 'Error'.
    ENDIF.
    COMMIT WORK.
    Send the email immediately.
    SUBMIT rsconn01
    WITH mode = 'INT'
    AND RETURN.
    Thanks,
    Naren

  • Send mail with attachment from webdynpro application

    hi,
    From a webdynpro application, the user will upload any files through the File upload ui element.These uploaded files has to go as an attachment in the mail which is being send to a particular ID ,when the user clicks the submit button in the form.
    can you please give me the code regarding this and help me in sending mail with attachment from a webdynpro application.
    Thanks in advance,
    shami.

    Hai,
    Properties props = System.getProperties();
           props.put("mail.smtp.host", "xx.xx.x.xx");
           Session session = Session.getDefaultInstance(props, null);
           Message msg = new MimeMessage(session);
           msg.setFrom(new InternetAddress("[email protected]"));
           msg.setRecipients(Message.RecipientType.TO,
           InternetAddress.parse("[email protected]", false));
           msg.setSubject(subject);
           msg.setText(body);
           msg.setHeader("X-Mailer", " Email");
           msg.setSentDate(new Date());
           MimeBodyPart messageBodyPart = new MimeBodyPart();
           messageBodyPart.setText("Hai , This mail Generated By the  Program");
          Multipart multipart = new MimeMultipart();
           multipart.addBodyPart(messageBodyPart);
            messageBodyPart = new MimeBodyPart();
            DataSource source = new FileDataSource("C:\nag.xls");//Here you need to give the Path of uploaded File
            messageBodyPart.setDataHandler( new DataHandler(source));
            messageBodyPart.setFileName("nag.xls");
            multipart.addBodyPart(messageBodyPart);
            // Put parts in message
            msg.setContent(multipart);
           Transport.send(msg);
    Regards,
    Naga

  • Send mail with attached file without using Repository

    Hello,
    I want to know if have a way to Send mail with attached file without using Repository.
    Regards
    Elad

    Elad,
    Check this article where a image has been picked by the file adapter and sent as an attachment to the mail adapter.
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816">Sending an Image File Through XI in a File-to-Mail Scenario</a>
    For how to proceed without integration repository content look into this blog,
    <a href="/people/william.li/blog/2006/09/08/how-to-send-any-data-even-binary-through-xi-without-using-the-integration-repository">How to send any data (even binary) through XI, without using the Integration Repository</a>
    Combining these 2 you have the solution.
    Regards
    Bhavesh

  • Send mail with attachment

    Hello all.
    I have a problem that i dont know how to resolve: I need to send an email to some adresses  with an attachment ( an excel file stored on the server's drive) How can it be done?
    The email has to be sent by a job that should do this operation each day.
    Thank you,
    Cristian.
    Message was edited by:
            Cristian Boartes

    see this
    Sending mail with attachment
    This program will allowed you to send email with attachment.
    First, specify the attachment file from your local hardisk and execute.
    Next, specify the sender email address and click the send button.
    report y_cr17_mail.
    data method1 like sy-ucomm.
    data g_user like soudnamei1.
    data g_user_data like soudatai1.
    data g_owner like soud-usrnam.
    data g_receipients like soos1 occurs 0 with header line.
    data g_document like sood4 .
    data g_header like sood2.
    data g_folmam like sofm2.
    data g_objcnt like soli occurs 0 with header line.
    data g_objhead like soli occurs 0 with header line.
    data g_objpara  like selc occurs 0 with header line.
    data g_objparb  like soop1 occurs 0 with header line.
    data g_attachments like sood5 occurs 0 with header line.
    data g_references like soxrl occurs 0 with header line.
    data g_authority like sofa-usracc.
    data g_ref_document like sood4.
    data g_new_parent like soodk.
    data: begin of g_files occurs 10 ,
      text(4096) type c,
       end of g_files.
    data : fold_number(12) type c,
           fold_yr(2) type c,
           fold_type(3) type c.
    parameters ws_file(4096) type c default 'c:\debugger.txt'.
    Can me any file fromyour pc ....either xls or word or ppt etc ...
    g_user-sapname = sy-uname.
    call function 'SO_USER_READ_API1'
    exporting
       user                            = g_user
       PREPARE_FOR_FOLDER_ACCESS       = ' '
    importing
       user_data                       = g_user_data
    EXCEPTIONS
       USER_NOT_EXIST                  = 1
       PARAMETER_ERROR                 = 2
       X_ERROR                         = 3
       OTHERS                          = 4
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    fold_type = g_user_data-outboxfol+0(3).
    fold_yr = g_user_data-outboxfol+3(2).
    fold_number =  g_user_data-outboxfol+5(12).
    clear g_files.
    refresh : g_objcnt,
      g_objhead,
      g_objpara,
      g_objparb,
      g_receipients,
      g_attachments,
      g_references,
      g_files.
    method1 = 'SAVE'.
    g_document-foltp  = fold_type.
    g_document-folyr   = fold_yr.
    g_document-folno   = fold_number.
    g_document-objtp   = g_user_data-object_typ.
    *g_document-OBJYR   = '27'.
    *g_document-OBJNO   = '000000002365'.
    *g_document-OBJNAM = 'MESSAGE'.
    g_document-objdes   = 'sap-img.com testing by program'.
    g_document-folrg   = 'O'.
    *g_document-okcode   = 'CHNG'.
    g_document-objlen = '0'.
    g_document-file_ext = 'TXT'.
    g_header-objdes =  'sap-img.com testing by program'.
    g_header-file_ext = 'TXT'.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = sy-uname
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
      FOLMEM_DATA        =
      RECEIVE_DATA       =
    File from the pc to send...
    method1 = 'ATTCREATEFROMPC'.
    g_files-text = ws_file.
    append g_files.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
    method1 = 'SEND'.
    g_receipients-recnam = 'MK085'.
    g_receipients-recesc = 'B'.
    g_receipients-sndex = 'X'.
    append  g_receipients.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header.
    *-- End of Program
    <b>also try this one for background scheduling the same</b>
    Sending mail with attachment report in Background
    Pay attention because it’s working with output list from spool converted to pdf.
    =================================================================================
    z_send_email_fax_global
    FUNCTION-POOL z_gfaian_mail_fax.            “MESSAGE-ID ..
    WORK TABLE AREAS
    TABLES: tsp01.
    INTERNAL TABLES
    DATA: lt_rec_tab LIKE STANDARD TABLE OF soos1 WITH HEADER LINE,
    lt_note_text   LIKE STANDARD TABLE OF soli  WITH HEADER LINE,
    lt_attachments LIKE STANDARD TABLE OF sood5 WITH HEADER LINE.
    DATA: lt_objcont LIKE STANDARD TABLE OF soli WITH HEADER LINE,
    lt_objhead LIKE STANDARD TABLE OF soli WITH HEADER LINE.
    DATA: pdf_format LIKE STANDARD TABLE OF tline WITH HEADER LINE.
    TYPES: BEGIN OF y_files,
    file(60) TYPE c,
    END OF y_files.
    DATA: lt_files TYPE STANDARD TABLE OF y_files WITH HEADER LINE.
    DATA: l_objcont     LIKE soli OCCURS 0 WITH HEADER LINE.
    DATA: l_objhead     LIKE soli OCCURS 0 WITH HEADER LINE.
    STRUCTURES
    DATA: folder_id      LIKE soodk,
    object_id      LIKE soodk,
    link_folder_id LIKE soodk,
    g_document     LIKE sood4,
         g_header_data  LIKE sood2,
    g_folmem_data  LIKE sofm2,
    g_header_data  LIKE sood2,
    g_receive_data LIKE soos6,
    g_ref_document LIKE sood4,
    g_new_parent   LIKE soodk,
    l_folder_id    LIKE sofdk,
    v_email(50).
    DATA: hd_dat  like sood1.
    VARIABLES
    DATA: client  LIKE tst01-dclient,
    name    LIKE tst01-dname,
    objtype LIKE rststype-type,
    type    LIKE rststype-type.
    DATA: numbytes TYPE i,
    arc_idx LIKE toa_dara,
    pdfspoolid LIKE tsp01-rqident,
    jobname LIKE tbtcjob-jobname,
    jobcount LIKE tbtcjob-jobcount,
    is_otf.
    DATA: outbox_flag LIKE sonv-flag VALUE ‘X’,
    store_flag  LIKE sonv-flag,
    delete_flag LIKE sonv-flag,
    owner       LIKE soud-usrnam,
    on          LIKE sonv-flag VALUE ‘X’,
    sent_to_all LIKE sonv-flag,
    g_authority LIKE sofa-usracc,
    w_objdes    LIKE sood4-objdes.
    DATA: c_file LIKE rlgrap-filename,
    n_spool(6) TYPE n.
    DATA: cancel.
    DATA: desired_type  LIKE sood-objtp,
    real_type LIKE sood-objtp,
    attach_type LIKE sood-objtp,
    otf LIKE sood-objtp VALUE ‘OTF’, ” SAPscript Ausgabeformat
    ali LIKE sood-objtp VALUE ‘ALI’. ” ABAP lists
    CONSTANTS
    CONSTANTS: ou_fol LIKE sofh-folrg              VALUE ‘O’,
    c_objtp    LIKE g_document-objtp    VALUE ‘RAW’,
    c_file_ext LIKE g_document-file_ext VALUE ‘TXT’.
    =================================================================================
    z_send_email_fax2
    FUNCTION z_faian_mail_fax2.
    ””Interface local:
    *”  IMPORTING
    *”     REFERENCE(SRC_SPOOLID) LIKE  TSP01-RQIDENT
    *”     REFERENCE(FAX_MAIL_NUMBER) TYPE  SO_NAME
    *”     REFERENCE(HEADER_MAIL) TYPE  SO_OBJ_DES
    *”     REFERENCE(OBJECT_TYPE) TYPE  SO_ESCAPE
    *”  TABLES
    *”      LT_BODY_EMAIL STRUCTURE  SOLI
    *”  EXCEPTIONS
    *”      ERR_NO_ABAP_SPOOLJOB
    Fist part: Verify if the spool really exists
    SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
    IF sy-subrc NE 0.
    RAISE err_no_abap_spooljob. “doesn’t exist
    ELSE.
    client = tsp01-rqclient.
    name   = tsp01-rqo1name.
    CALL FUNCTION ‘RSTS_GET_ATTRIBUTES’
    EXPORTING
    authority     = ‘SP01&#8242;
    client        = client
    name          = name
    part          = 1
    IMPORTING
    type          = type
    objtype       = objtype
    EXCEPTIONS
    fb_error      = 1
    fb_rsts_other = 2
    no_object     = 3
    no_permission = 4
    OTHERS        = 5.
    IF objtype(3) = ‘OTF’.
    desired_type = otf.
    ELSE.
    desired_type = ali.
    ENDIF.
    CALL FUNCTION ‘RSPO_RETURN_SPOOLJOB’
    EXPORTING
    rqident              = src_spoolid
    desired_type         = desired_type
    IMPORTING
    real_type            = real_type
    TABLES
    buffer               = l_objcont
    EXCEPTIONS
    no_such_job          = 14
    type_no_match        = 94
    job_contains_no_data = 54
    no_permission        = 21
    can_not_access       = 21
    read_error           = 54.
    IF sy-subrc EQ 0.
    attach_type = real_type.
    ENDIF.
    CALL FUNCTION ‘SO_FOLDER_ROOT_ID_GET’
    EXPORTING
    owner     = sy-uname
    region    = ou_fol
    IMPORTING
    folder_id = l_folder_id
    EXCEPTIONS
    OTHERS    = 5.
    fill out informations about the header of the email
    CLEAR: g_document.
    g_document-foltp     = l_folder_id-foltp.
    g_document-folyr     = l_folder_id-folyr.
    g_document-folno     = l_folder_id-folno.
    g_document-objtp     = c_objtp.
    g_document-objdes    = header_mail.
    g_document-file_ext  = c_file_ext.
    g_header_data-objdes    = header_mail.
    CALL FUNCTION ‘SO_DOCUMENT_REPOSITORY_MANAGER’
    EXPORTING
    method      = ‘SAVE’
    office_user = sy-uname
    IMPORTING
    authority   = g_authority
    TABLES
    objcont     = lt_body_email
    attachments = lt_attachments
    CHANGING
    document    = g_document
    header_data = g_header_data
    EXCEPTIONS
    OTHERS      = 1.
    folder_id-objtp = l_folder_id-foltp.
    folder_id-objyr = l_folder_id-folyr.
    folder_id-objno = l_folder_id-folno.
    object_id-objtp = c_objtp.
    object_id-objyr = g_document-objyr.
    object_id-objno = g_document-objno.
    link_folder_id-objtp = l_folder_id-foltp.
    link_folder_id-objyr = l_folder_id-folyr.
    link_folder_id-objno = l_folder_id-folno.
    REFRESH lt_rec_tab.
       CLEAR lt_rec_tab.
       lt_rec_tab-sel        = ‘X’.
       lt_rec_tab-recesc     = object_type.   “This field for FAX/MAIL
       lt_rec_tab-recnam     = ‘U-’.
       lt_rec_tab-deliver    = ‘X’.
       lt_rec_tab-not_deli   = ‘X’.
       lt_rec_tab-read       = ‘X’.
       lt_rec_tab-mailstatus = ‘E’.
       lt_rec_tab-adr_name   = fax_mail_number.
       lt_rec_tab-sortfield  = fax_mail_number.
       lt_rec_tab-recextnam  = fax_mail_number.
       lt_rec_tab-sortclass  = ‘5&#8242;.
       APPEND lt_rec_tab.
    lt_rec_tab-recextnam = fax_mail_number.
    lt_rec_tab-recesc = object_type.
    lt_rec_tab-sndart = ‘INT’.
    lt_rec_tab-sndpri = 1.
    APPEND lt_rec_tab.
    lt_files-file = c_file.
    APPEND lt_files.
    begin of insertion by faianf01
    hd_dat-objdes = header_mail.
    CALL FUNCTION ‘SO_ATTACHMENT_INSERT’
    EXPORTING
    object_id                  = object_id
    attach_type                = attach_type
    object_hd_change           = hd_dat
    owner                      = sy-uname
    TABLES
    objcont                    = l_objcont
    objhead                    = l_objhead
    EXCEPTIONS
    active_user_not_exist      = 35
    communication_failure      = 71
    object_type_not_exist      = 17
    operation_no_authorization = 21
    owner_not_exist            = 22
    parameter_error            = 23
    substitute_not_active      = 31
    substitute_not_defined     = 32
    system_failure             = 72
    x_error                    = 1000.
    IF sy-subrc > 0.
    ENDIF.
    end of insertion by faianf01
    send email from SAPOFFICE
    CALL FUNCTION ‘SO_OBJECT_SEND’
    EXPORTING
    folder_id                  = folder_id
    object_id                  = object_id
    outbox_flag                = outbox_flag
    link_folder_id             = link_folder_id
    owner                      = sy-uname
                 check_send_authority       = ‘X’
    TABLES
    receivers                  = lt_rec_tab
                 note_text                  = lt_note_text
    EXCEPTIONS
    active_user_not_exist      = 35
    communication_failure      = 71
    component_not_available    = 1
    folder_no_authorization    = 5
    folder_not_exist           = 6
    forwarder_not_exist        = 8
    object_no_authorization    = 13
    object_not_exist           = 14
    object_not_sent            = 15
    operation_no_authorization = 21
    owner_not_exist            = 22
    parameter_error            = 23
    substitute_not_active      = 31
    substitute_not_defined     = 32
    system_failure             = 72
    too_much_receivers         = 73
    user_not_exist             = 35.
    ENDIF.
    ENDFUNCTION.
    =================================================================================
    z_send_email_fax
    FUNCTION ZCBFS_SEND_MAIL.
    ””Interface local:
    *”  IMPORTING
    *”     REFERENCE(SRC_SPOOLID) LIKE  TSP01-RQIDENT
    *”     REFERENCE(HEADER_MAIL) TYPE  SO_OBJ_DES
    *”  TABLES
    *”      LIST_FAX_MAIL_NUMBER STRUCTURE  SOLI
    *”  EXCEPTIONS
    *”      ERR_NO_ABAP_SPOOLJOB
    DATA: vg_achou(1) TYPE n.
    Fist part: Verify if the spool really exists
    vg_achou = 1.
    DO 60 TIMES.
    SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
    IF sy-subrc IS INITIAL.
    CLEAR vg_achou.
    EXIT.
    ELSE.
    WAIT UP TO 1 SECONDS.
    ENDIF.
    ENDDO.
    IF vg_achou = 1.
    RAISE err_no_abap_spooljob. “doesn’t exist
    ENDIF.
    client = tsp01-rqclient.
    name   = tsp01-rqo1name.
    CALL FUNCTION ‘RSTS_GET_ATTRIBUTES’
    EXPORTING
    authority     = ‘SP01&#8242;
    client        = client
    name          = name
    part          = 1
    IMPORTING
    type          = type
    objtype       = objtype
    EXCEPTIONS
    fb_error      = 1
    fb_rsts_other = 2
    no_object     = 3
    no_permission = 4
    OTHERS        = 5.
    IF objtype(3) = ‘OTF’.
    desired_type = otf.
    ELSE.
    desired_type = ali.
    ENDIF.
    CALL FUNCTION ‘RSPO_RETURN_SPOOLJOB’
    EXPORTING
    rqident              = src_spoolid
    desired_type         = desired_type
    IMPORTING
    real_type            = real_type
    TABLES
    buffer               = l_objcont
    EXCEPTIONS
    no_such_job          = 14
    type_no_match        = 94
    job_contains_no_data = 54
    no_permission        = 21
    can_not_access       = 21
    read_error           = 54.
    IF sy-subrc EQ 0.
    attach_type = real_type.
    ENDIF.
    CALL FUNCTION ‘SO_FOLDER_ROOT_ID_GET’
    EXPORTING
    owner     = sy-uname
    region    = ou_fol
    IMPORTING
    folder_id = l_folder_id
    EXCEPTIONS
    OTHERS    = 5.
    fill out informations about the header of the email
    CLEAR: g_document.
    g_document-foltp     = l_folder_id-foltp.
    g_document-folyr     = l_folder_id-folyr.
    g_document-folno     = l_folder_id-folno.
    g_document-objtp     = c_objtp.
    g_document-objdes    = header_mail.
    g_document-file_ext  = c_file_ext.
    g_header_data-objdes    = header_mail.
    CALL FUNCTION ‘SO_DOCUMENT_REPOSITORY_MANAGER’
    EXPORTING
    method      = ‘SAVE’
    office_user = sy-uname
    IMPORTING
    authority   = g_authority
    TABLES
    attachments = lt_attachments
    CHANGING
    document    = g_document
    header_data = g_header_data
    EXCEPTIONS
    OTHERS      = 1.
    folder_id-objtp = l_folder_id-foltp.
    folder_id-objyr = l_folder_id-folyr.
    folder_id-objno = l_folder_id-folno.
    object_id-objtp = c_objtp.
    object_id-objyr = g_document-objyr.
    object_id-objno = g_document-objno.
    link_folder_id-objtp = l_folder_id-foltp.
    link_folder_id-objyr = l_folder_id-folyr.
    link_folder_id-objno = l_folder_id-folno.
    REFRESH lt_rec_tab.
    LOOP AT LIST_FAX_MAIL_NUMBER.
    lt_rec_tab-recextnam = LIST_FAX_MAIL_NUMBER-LINE.
    lt_rec_tab-recesc = ‘U’.
    lt_rec_tab-sndart = ‘INT’.
    lt_rec_tab-sndpri = 1.
    APPEND lt_rec_tab.
    ENDLOOP.
    lt_files-file = c_file.
    APPEND lt_files.
    hd_dat-objdes = header_mail.
    CALL FUNCTION ‘SO_ATTACHMENT_INSERT’
    EXPORTING
    object_id                  = object_id
    attach_type                = attach_type
    object_hd_change           = hd_dat
    owner                      = sy-uname
    TABLES
    objcont                    = l_objcont
    objhead                    = l_objhead
    EXCEPTIONS
    active_user_not_exist      = 35
    communication_failure      = 71
    object_type_not_exist      = 17
    operation_no_authorization = 21
    owner_not_exist            = 22
    parameter_error            = 23
    substitute_not_active      = 31
    substitute_not_defined     = 32
    system_failure             = 72
    x_error                    = 1000.
    IF sy-subrc > 0.
    ENDIF.
    send email from SAPOFFICE
    CALL FUNCTION ‘SO_OBJECT_SEND’
    EXPORTING
    folder_id                  = folder_id
    object_id                  = object_id
    outbox_flag                = outbox_flag
    link_folder_id             = link_folder_id
    owner                      = sy-uname
    TABLES
    receivers                  = lt_rec_tab
    note_text                  = lt_note_text
    EXCEPTIONS
    active_user_not_exist      = 35
    communication_failure      = 71
    component_not_available    = 1
    folder_no_authorization    = 5
    folder_not_exist           = 6
    forwarder_not_exist        = 8
    object_no_authorization    = 13
    object_not_exist           = 14
    object_not_sent            = 15
    operation_no_authorization = 21
    owner_not_exist            = 22
    parameter_error            = 23
    substitute_not_active      = 31
    substitute_not_defined     = 32
    system_failure             = 72
    too_much_receivers         = 73
    user_not_exist             = 35.
    ENDFUNCTION.
    regards,
    srinivas
    <b>*reward for useful answers*</b>

  • Help regd in sending mails with attachment

    Hi All,
    I have a requirement to send mails with attachements.The attachments can be simple word , excel anything. Please help.Is there a way I can send these from workflows also?

    hi use this , this is one of the best examples for sending mail ....
    1. We can send files with attachment.
    However, There is some trick involved
    in the binary files.
    2. I have made a program (and it works fantastic)
    ONLY 6 LINES FOR EMAILING
    BELIEVE ME
    ITS A FANTASTIC PROGRAM.
    IT WILL WORK LIKE OUTLOOK EXPRESS !
    3. The user is provided with
    a) file name
    b) email address to send mail
    and it sends ANY FILE (.xls,.pdf .xyz..)
    Instantaneously !
    4. Make two things first :
    1. Include with the name : ZAMI_INCLFOR_MAIL
    2. Report with the name : ZAM_TEMP147 (any name will do)
    3. Activate both and execute (2)
    4. After providing filename, email adress
    5. Code for Include :
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    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 = 8
    IF sy-subrc 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    CODE FOR PROGRAM
    5.
    REPORT zam_temp147 .
    INCLUDE zami_inclfor_mail.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    regards,
    venkat.

  • Send mail with attachement

    i want to send mail with attachements. does wwv_flow_mail.send support this feature? how to do it?
    thanks,

    Please check this thread..
    Re: sending mails with attachment
    Hope this helps.
    Thanks

  • Sending mail with attachment and body.

    Hi Experts,
    I have a requirement of sending a mail with an attachment and also the mail will have a body whose content will be same as that in the attachment.Subject of the mail will also be configured dynamically.Though I am able to send the mail with the attachment but I am not able to configure the body whose content will be same as that of the attachment.
    I have unchecked the "Use Mail Package" and has hard-coded the "TO","From" field for sending the mail with attachment.
    Can you please check and let me know how to configure the body which will be same as that of the attachment.
    Thanks and Regards
    Atanu Mazumdar

    Hi,
    Use MTB module and then one of the parameter which can allow you to send message in attachment as well as in message body.
    Transform.ContentDisposition: it helps us to decide if we want to send the payload as an attachment or in the message body. If we give the Parameter value as u201Cattachmentu201D then we will have the payload attached in the mail and if we assign this value as u201Cinlineu201D the payload will go in the mail body.
    Hope this helps you..
    Regards....

  • How to import photos from Mail to iPhoto and preserve the date created?

    I have several photos sent to me via email attachments in Mail which I want to "add to iphoto."  When I do this, the original date of the photo changes to "today's date." 
    When I drag the photo to the desk top, the file (photo) properties change and the date changes to "today's date."
    Is there a way to import photos and preserve the original date the photo was taken?  For example,  if my family finally got around to sending me photos from 4th of July, I know the date is 7/4/2012, not today's date, 10/9/2012. 
    I want to avoid the time/work of doing batch changes on countless photos I want to add to iphoto. 
    iphoto 11
    mail 5.3
    Lion 10.7.5

    Larry, I need more information...
    Using what you said, I ran some tests using photos taken with my digital camera in iPhoto.  My photos show the following information in the "information" sidebar:
    •type of camera
    •Flash on
    •Format size
    •File size (MB)
    •File type (jpeg)
    •Frame "number"
    •Month/day/year/hour/min/sec/AM-PM
    Then I tried to email a photo to myself:  I have tried:  "share," "attach," "drag/drop" a photo into email and sent it to myself as a test.  Once the photo arrives in my Mail inbox, I have tried various ways to add this "test" photo into iPhoto:
    "Add to iphoto"
    "drag into iphoto"
    "export into iphoto"
    Each time, iphoto created the photo with "today's date."  In the past, I would get an alert:  Photo already exists in iphoto, do you still want to import?  Duplicate or Cancel
    Can you elaborate on, "if the photo properties are present and correctly formatted then iPhoto uses them."
    When I drag a photo to the desktop and double-click to preview the photo, the top of the preview window says:
    P1009.jpg -- locked (gray lettering of the word "locked")
    Is there a setting I need to change to "unlock" the properties of my photos?*
    Thanks!!
    MG
    *My original post focuses on importing photos sent from other people.  I am hoping if I can solve the matter with my own photos, other photos will import with original dates created, too.

  • Send Mail with Attachment to Outlook - Version 3.1i

    Hi Every one,
           I need to draft a logic in 3.1i system that sends a mail to Microsoft outlook inbox with attachments.
    The below flow of logic is the core part of the code that I am using for mails without attachments.
      OPEN DATASET P_FNAME FOR OUTPUT IN TEXT MODE.
      IF P_FROM NE SPACE.
        CONCATENATE 'From:'(MFR) P_FROM INTO P_FROM SEPARATED BY SPACE.
        TRANSFER P_FROM TO P_FNAME.
      ENDIF.
      IF P_TO NE SPACE.
        CONCATENATE 'To:'(MTO) P_TO INTO P_TO SEPARATED BY SPACE.
        TRANSFER P_TO TO P_FNAME.
      ENDIF.
      IF P_CC NE SPACE.
        CONCATENATE 'Cc:'(MCC) P_CC INTO P_CC SEPARATED BY SPACE.
        TRANSFER P_CC TO P_FNAME.
      ENDIF.
      IF P_BCC NE SPACE.
        CONCATENATE 'Bcc:'(MBC) P_BCC INTO P_BCC SEPARATED BY SPACE.
        TRANSFER P_BCC TO P_FNAME.
      ENDIF.
      IF P_SUB NE SPACE.
        CONCATENATE 'Subject:'(MSB) P_SUB INTO P_SUB SEPARATED BY SPACE.
        TRANSFER P_SUB TO P_FNAME.
      ENDIF.
      LOOP AT S_BODY.
        TRANSFER S_BODY-LOW TO P_FNAME.
      ENDLOOP.
      CLOSE DATASET P_FNAME.
    Run External Command: SENDMAIL
      CLEAR PARCOM.
      REFRESH OUT_LINES.
    concatenate 'sendmail -t < '     p_fname into parcom.
    Execute Command
    call         'system'        id         'COMMAND'   field   PARCOM   id   'TAB'   field    out_lines-SYS   .
    I have tried creating another file in AL11 and using it as attachment after the transfer of subject text in the above code, like -
        CONCATENATE 'Attach:'(MAT) '/usr/sap/GS1/DVEBMGS20/work/attach.txt INTO P_ATTACH SEPARATED BY SPACE.
        TRANSFER P_ATTACH TO P_FNAME.
    But, this did not work.
    Need your help in extending the code to send attachments.
    Thanks in Advance,
    Regards
    Govardhan
    Edited by: Gova12 on Sep 8, 2009 12:25 PM
    Edited by: Gova12 on Sep 8, 2009 12:57 PM

    < DATA:   i_message     TYPE STANDARD TABLE OF solisti1,
            i_attach      TYPE STANDARD TABLE OF solisti1,
            i_attach_body TYPE STANDARD TABLE OF solisti1,
            i_suc_notify  TYPE STANDARD TABLE OF zifdl,
            i_mail_rcpnts TYPE STANDARD TABLE OF zbss_mail.
    Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment.
    *&      Form  BUILD_XLS_DATA_TABLE
    Populate table with detaisl to be entered into .xls file
    FORM build_xls_data_table .
      CONSTANTS: l_c_head1   TYPE  char20  VALUE 'Credit Card Type', "#EC NOTEXT
                 l_c_head2   TYPE  char20  VALUE 'OrigSysRef',
                 l_c_head3   TYPE  char20  VALUE 'OrderNum',
                 l_c_head4   TYPE  char20  VALUE 'OrigSysLineRef',
                 l_c_head5   TYPE  char20  VALUE 'LineNum',
                 l_c_head6   TYPE  char20  VALUE 'ItemNum',
                 l_c_head7   TYPE  char20  VALUE 'LineAmt',
                 l_c_head8   TYPE  char20  VALUE 'ScheduleDate',
                 l_c_head9   TYPE  char20  VALUE 'ReqDate',
                 l_c_head10  TYPE  char20  VALUE 'PromiseDate',
                 l_c_head11  TYPE  char20  VALUE 'AuthReqDate'.
      DATA:
             l_vtext            TYPE char50,                     "Credit Card Type
             l_bstnk            TYPE char20,                     "OrigSysRef
             l_vbeln            TYPE char20,                     "OrderNum
             l_posex            TYPE char20,                     "OrigSysLineRef
             l_posnr            TYPE char20,                     "LineNum
             l_matnr            TYPE char20,                     "ItemNum
             l_netwr            TYPE char20,                     "LineAmt
             l_lddat            TYPE char20,                     "ScheduleDate
             l_vdatu            TYPE char20,                     "ReqDate
             l_edatu            TYPE char20,                     "PromiseDate
             l_req_date         TYPE char20,                     "AuthReqDate
             l_sub_tot          TYPE vbap-netwr,
             l_sto              TYPE char20,
             l_v_datum          TYPE char10,
             l_v_time           TYPE char10,
             l_dummy            TYPE char20.
      DATA:  l_wa_attach           TYPE solisti1,
             l_wa_attach_body      TYPE solisti1,
             l_wa_final            TYPE t_final.
      CLEAR: l_dummy.
      CONCATENATE sy-datum(4) sy-datum4(2) sy-datum6(2) INTO l_v_datum SEPARATED BY '/'.
      CONCATENATE sy-uzeit(2) sy-uzeit2(2) sy-uzeit4(2) INTO l_v_time  SEPARATED BY ':'.
    This table  contain actual column headings for the fields in the attachment
      CLEAR: l_wa_attach.
      CONCATENATE  text-011
                   cl_abap_char_utilities=>horizontal_tab
                   text-003
                   cl_abap_char_utilities=>horizontal_tab
                   cl_abap_char_utilities=>horizontal_tab
                   cl_abap_char_utilities=>horizontal_tab
                   text-021
                   l_v_datum
                   l_v_time
                   cl_abap_char_utilities=>cr_lf
                   cl_abap_char_utilities=>cr_lf
                   INTO l_wa_attach SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
      APPEND  l_wa_attach TO i_attach.
      CLEAR: l_wa_attach.
    This table  contain actual column headings for the fields in the attachment
      CONCATENATE   l_c_head1 l_c_head2 l_c_head3 l_c_head4 l_c_head5
                    l_c_head6 l_c_head7 l_c_head8 l_c_head9 l_c_head10
                    l_c_head11 cl_abap_char_utilities=>cr_lf
                    INTO l_wa_attach SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
      APPEND  l_wa_attach TO i_attach.
      CLEAR: l_wa_attach.
    This table contain the actual contents of the attachment
      SORT i_final BY vbeln posnr.
      CLEAR: l_wa_final,l_wa_attach_body.
      LOOP AT i_final INTO l_wa_final.
        WRITE :
                l_wa_final-vtext    TO l_vtext,
                l_wa_final-bstnk    TO l_bstnk,
                l_wa_final-vbeln    TO l_vbeln,
                l_wa_final-posex    TO l_posex,
                l_wa_final-posnr    TO l_posnr,
                l_wa_final-matnr    TO l_matnr,
                l_wa_final-netwr    TO l_netwr CURRENCY 'VBAP-WAERK',
                l_wa_final-lddat    TO l_lddat,
                l_wa_final-vdatu    TO l_vdatu,
                l_wa_final-edatu    TO l_edatu,
                l_wa_final-req_date TO l_req_date.
        l_sub_tot = l_sub_tot + l_wa_final-netwr.
        CONCATENATE l_dummy
                    l_vtext l_bstnk l_vbeln l_posex l_posnr l_matnr
                    l_netwr l_lddat l_vdatu l_edatu l_req_date
                    INTO l_wa_attach_body SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
        APPEND  l_wa_attach_body TO i_attach_body.
        CLEAR: l_wa_attach_body.
        AT END OF vbeln.
          READ TABLE i_final INTO l_wa_final INDEX sy-tabix.
          MOVE l_sub_tot TO l_sto.
          CONCATENATE cl_abap_char_utilities=>horizontal_tab
                      cl_abap_char_utilities=>horizontal_tab
                      cl_abap_char_utilities=>horizontal_tab
                      'Order total'
                      l_sto
                      cl_abap_char_utilities=>cr_lf
                 INTO l_wa_attach_body SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
          APPEND  l_wa_attach_body TO i_attach_body.
          CLEAR: l_sub_tot,l_sto,l_wa_attach_body.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
      DATA:   l_v_desc  TYPE sood1-objdes,
              l_wa_suc_notify TYPE zifdl,
              l_wa_mail_rcpnts TYPE zbss_mail.
    Get the mail ids from distribution list
      REFRESH: i_suc_notify.
      SELECT * INTO TABLE i_suc_notify
                      FROM zifdl
                      WHERE zdstlist EQ p_disid.
      IF sy-subrc <> c_zero.
      Show exit msg if there is no distribution list maintained
        MESSAGE e002 WITH  text-014 p_disid.
      ENDIF.
    format the email id details
      CLEAR: l_wa_suc_notify,l_wa_mail_rcpnts.
      LOOP AT i_suc_notify INTO l_wa_suc_notify .
        IF l_wa_suc_notify-zuserid CA '@'.
          l_wa_mail_rcpnts-l_adr_name = l_wa_suc_notify-zuserid.
        ELSE.
          l_wa_mail_rcpnts-usrnam = l_wa_suc_notify-zuserid.
        ENDIF.
        APPEND l_wa_mail_rcpnts TO i_mail_rcpnts.
        CLEAR: l_wa_mail_rcpnts,l_wa_suc_notify.
      ENDLOOP.
    Populate message body text
      PERFORM populate_email_message_body.
    Send the report output generated to the list of recipients
      MOVE text-012 TO l_v_desc.
    Send the e-mail with attachment
      TRY.
        -------- create persistent send request ------------------------
          send_request = cl_bcs=>create_persistent( ).
        -------- create and set document with attachment ---------------
        create document from internal table with text
          document = cl_document_bcs=>create_document(
                          i_type    = 'RAW'
                          i_text    = i_content_body[]
                          i_subject = subject ).
    Check if Attachment should be sent in mail
          IF p_skip_attach IS INITIAL.
            IF i_attachment_type = 'ALI'.
              CALL METHOD document->add_attachment
                EXPORTING
                  i_attachment_type    = i_attachment_type
                  i_attachment_subject = l_filename
                  i_att_content_hex    = i_content_hex.
            ELSE.
    Get No of lines
              DESCRIBE TABLE i_attach LINES l_lines.
    Size to multiplied by no of lines
              l_size = l_lines * 255.
              CALL METHOD document->add_attachment
                EXPORTING
                  i_attachment_type    = i_attachment_type
                  i_attachment_size    = l_size
                  i_attachment_subject = i_filename
                  i_att_content_text   = i_attach[].
            ENDIF.
          ENDIF.
        add document to send request
          CALL METHOD send_request->set_document( document ).
        --------- add recipient (e-mail address) -----------------------
          LOOP AT i_receivers INTO l_receiver_wa.
            CLEAR l_mailaddr.
            l_mailaddr = l_receiver_wa-receiver.
            recipient = cl_cam_address_bcs=>create_internet_address(
                                                l_mailaddr ).
        add recipient with its respective attributes to send request
            CALL METHOD send_request->add_recipient
              EXPORTING
                i_recipient  = recipient
                i_express    = express
               i_copy       = ' '
               i_blind_copy = ' '
                i_copy       = l_receiver_wa-copy
                i_blind_copy = l_receiver_wa-blind_copy
                i_no_forward = ' '.
          ENDLOOP.
    *Set sender based on l_userid
          lo_sender = cl_sapuser_bcs=>create( l_userid ).
          CALL METHOD send_request->set_sender( EXPORTING i_sender = lo_sender ).
        ---------- send document ---------------------------------------
          CALL METHOD send_request->send(
            EXPORTING
              i_with_error_screen = 'X'
            RECEIVING
              result              = sent_to_all ).
          IF i_bypass_commit IS INITIAL.
            COMMIT WORK.
          ENDIF.
    *                     exception handling
        CATCH cx_bcs INTO bcs_exception.
      ENDTRY. >
    Edited by: sugunav on Sep 8, 2009 4:41 PM

Maybe you are looking for

  • Adding a new UDF throws a null pointer exception and modifying user.xml

    Hello, I have a two part question. i. I am trying to add a UDF (using Advanced>User Configuration..Attributes) to a fully configured OIM i.e. oim with reconciliation and provisioning from and to resources but it throws a null pointer exception. Look

  • Issue with Reading and Writing to a File

    Hello all, I'm having trouble when I run the following example; import java.io.FileReader; import java.io.FileWriter; import java.io.BufferedReader; import java.io.PrintWriter; import java.io.IOException; public class ReadWriteTextFile {     private

  • Oracle 10g Installation nn solaris 10 X86

    I have installed Oralce 10.1.0.3 in Solaris 10 X86 using the procedure given without creating the database.(Installing the binaries) Hardware:Sun fire V20z. When i tried creating Database using DBCA,it was throwing lots of error. The errors are: 1) O

  • Odd behavior when duplicating pages

    I have run into some odd behavior when duplicating pages. First I spent many hours trying to acomplish a double trigger effect in which the last trigger opened a large image in a pop up window. Thanks to help from agm 123 and Sachin Hasija  see the p

  • Why can't I rename a really long podcast name?

    I'm forced to keep the name that is associated with the podcast. Why is that? Even iTunes 8.0 does not support this feature.