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.

Similar Messages

  • 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

  • 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.

  • 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 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

  • 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

  • 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.

  • 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.

  • 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 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>

  • 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....

  • Mail_Receiver: Send Mail with attachment

    Hi everybody,
    I need some help. I want to send a mail with attachment.
    for this I have imported SAPs xsd for the mail adapter.
    I wonder how to map the target fields?
    The following causes five! attachments in SXMB_MONI and the adapter throws
    java.lang.IllegalArgumentException: can't parse argument number
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
       <ns0:Message1>
          <ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">
             <Subject>SubjctName</Subject>
             <From>mailadress</From>
             <To>mailadress</To>
             <Content_Type>text/plain; charset=&quot;ISO-8859-1&quot;</Content_Type>
             <Content_Description>
                <attachment filename="filename.txt">This should be the content of the attachment</attachment>
             </Content_Description>
             <Content>Constant</Content>
          </ns1:Mail>
       </ns0:Message1>
    </ns0:Messages>
    How do I have to foll the target fields?
    Thanks regards
    Mario

    Hi
    the following links may help you :
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1685 [original link is broken] [original link is broken] [original link is broken]
    http://help.sap.com/saphelp_nw04/helpdata/en/3c/b4a6490a08cd41a8c91759c3d2f401/content.htm
    /people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure
    XI Mail Adapter: An approach for sending emails with attachment with help of Java mapping
    Also reffer to the below mentioned thread;
    Regarding mail sent with an excel attachment
    Regard's
    Chetan Ahuja

  • How to send mail with attachment

    Hi,
    How to send mail with word document as attachment in oracle pl/sql.
    kindly help me .
    thank you
    regards
    P Prakash

    create or replace procedure pdf_mail(
        p_sender     varchar2, -- sender, example: 'Me <[email protected]>'
        p_recipients varchar2, -- recipients, example: 'Someone <[email protected]>'
        p_subject    varchar2, -- subject
    p_text   varchar2, -- text
    p_filename  varchar2, -- name of pdf file
    p_blob   blob     -- pdf file
    ) is
      conn      utl_smtp.connection;
      i number;
      len number;
    BEGIN
      conn := demo_mail.begin_mail(
        sender     => p_sender,
        recipients => p_recipients,
        subject    => p_subject,
        mime_type  => demo_mail.MULTIPART_MIME_TYPE);
      demo_mail.begin_attachment(
        conn         => conn,
        mime_type    => 'application/pdf',
        inline       => TRUE,
        filename     => p_filename,
        transfer_enc => 'base64');
        -- split the Base64 encoded attachment into multiple lines
       i   := 1;
       len := DBMS_LOB.getLength(p_blob);
       WHILE (i < len) LOOP
          IF(i + demo_mail.MAX_BASE64_LINE_WIDTH < len)THEN
             UTL_SMTP.Write_Raw_Data (conn
                                    , UTL_ENCODE.Base64_Encode(
                                            DBMS_LOB.Substr(p_blob, demo_mail.MAX_BASE64_LINE_WIDTH, i)));
          ELSE
             UTL_SMTP.Write_Raw_Data (conn
                                    , UTL_ENCODE.Base64_Encode(
                                            DBMS_LOB.Substr(p_blob, (len - i)+1,  i)));
          END IF;
          UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
          i := i + demo_mail.MAX_BASE64_LINE_WIDTH;
       END LOOP;
      demo_mail.end_attachment(conn => conn);
      demo_mail.attach_text(
        conn      => conn,
        data      => p_text,
        mime_type => 'text/html');
      demo_mail.end_mail( conn => conn );
    END;
    ref:
    http://www.plpdf.com/23-1725.html
    Edited by: Mahanam on Jan 9, 2011 10:32 PM

  • Problem in Sending mail with attachment (Excel sheet)

    Hi
    Iam using this FM   SO_NEW_DOCUMENT_ATT_SEND_API1  for sending mail with an attachment (excel sheet).
    the application is running fine , mail is going to other system .   but the excel sheet attachment contain only few rows  not all.
    and the body of the mail is not displaying . 
    Can any one help me. Thanks in advance.

    Hi,
    you can use cl_bcs classes for the same. I am using below code for same thng
      CONSTANTS:c_tab  TYPE c VALUE cl_bcs_convert=>gc_tab.
      CONSTANTS:c_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf.
      DATA o_send_request   TYPE REF TO cl_bcs.
      DATA o_document       TYPE REF TO cl_document_bcs.
      DATA o_recipient      TYPE REF TO if_recipient_bcs.
      DATA o_bcs_exception  TYPE REF TO cx_bcs.
      TRY.
        o_document = cl_document_bcs=>create_document(
          i_type    = 'RAW'
          i_text    = is_mail_text
          i_subject = text-005 ).
      ENDTRY.
    *create file header
    CONCATENATE
                    text-h00 c_tab text-h01 c_tab text-h02 c_tab text-h03 c_tab text-h04 c_tab
                    text-h52 c_tab text-h05 c_tab text-h06 c_tab text-h07 c_tab text-h08 c_tab text-h09 c_tab
                   c_crlf INTO w_data_string.
    Loop at itab which contains data to be send as attachment
    concatenate field1 field2 field3 c_crlf into your_string separated by  c_tab
    conatenate final string your_string into final_string.
    endloop.
    *Convert data into suitable excel format
      TRY.
          CALL METHOD cl_bcs_convert=>string_to_solix
            EXPORTING
              iv_string   = w_data_string
              iv_codepage = '4103'
              iv_add_bom  = 'X'
            IMPORTING
              et_solix    = w_binary_content.
        CATCH cx_bcs INTO o_bcs_exception.
          IF o_bcs_exception IS NOT INITIAL.
            w_exec_txt = o_bcs_exception->get_text( ).
            MESSAGE w_exec_txt TYPE 'S'.
          ENDIF.
      ENDTRY.
        add the spread sheet as attachment to document object
      CONCATENATE text-006 sy-datum INTO w_attach_name SEPARATED BY space.
      o_document->add_attachment(
        i_attachment_type    = 'xls'
        i_attachment_subject = w_attach_name
        i_att_content_hex    = w_binary_content ).
    *create persistent send request
      o_send_request = cl_bcs=>create_persistent( ).
        add document object to send request
      o_send_request->set_document( o_document ).
        create recipient object for external mail id
      w_mlrec = iw_recipent.
      TRY.
          o_recipient = cl_distributionlist_bcs=>getu_persistent(
              i_dliname = w_mlrec
              i_private = space ).
        CATCH cx_bcs INTO o_bcs_exception.
          IF o_bcs_exception IS NOT INITIAL.
            w_exec_txt = o_bcs_exception->get_text( ).
            MESSAGE w_exec_txt TYPE 'S'.
          ENDIF.
      ENDTRY.
        add recipient object to send request
      o_send_request->add_recipient( o_recipient ).
        ---------- send document ---------------------------------------
      w_sent_to_all = o_send_request->send( i_with_error_screen = 'X' ).
      IF w_sent_to_all EQ abap_true.
        COMMIT WORK.
      ENDIF.

Maybe you are looking for

  • Atualizar - Tabela/campo definido pelo usuário

    Senhores, como já disse antes, sou novo no SAP, e estou buscando conhecimento constantemente, quando aparece alguma demanda pra resolver venho pedir ajuda. Hoje o que eu preciso é o seguinte: No meu ambiente de Serviços - Chamado de Serviço, quando d

  • Internal Nested Classes

    How does access control work for nested classes? For example public class A  { public class B {     private int c;     private B() { }how does A refer to private members of B?

  • Conky and gnome issue

    I have a problem with conky under gnome, which is when I log out conky is not killed and when I log back in the old conky takes up 100% of one of my cpu cores. How can I get gnome to kill conky on logout? I have conky setup to load at login. Thanks f

  • Deceptive selling practices

    How come what they tell me my costs are going to be, and what they actually end up being, are two different things? Even though I clarify with a sales representative, again and again, during the selling process, what my monthly cost will be it always

  • "not enough disk space"...  WHAT?????

    Try to DL files using Safari. It claims there's not enough disk space. I've got 129GB of 148GB still available. Changed DL location. No change. Copied files from another computer via LAN - took the file with no problem - so NO space issue. Even insta