How to send attachment to internal mails

hi,
my requirement is ,
i have to send alv output as attachment through mail to internal(sap) users.
could you please some one provide me some solution

I am enclosing the sample code to trigger an email, The logic for this is in comments, check this I am shure yuor problem will be solved.
*& Report ZGBL_SLA_PER
REPORT zgbl_sla_per NO STANDARD PAGE HEADING LINE-COUNT 26(3) MESSAGE-ID
zmsg2.
DECLARATION OF DB TABLES
TABLES: zncrfid, zrule_id.
DECLARATION OF INTERNAL TABLES
DATA: BEGIN OF ncrf OCCURS 0,
zncrf_id(15) TYPE c,
zncrf_l4_name(60) TYPE c,
z9gl_sla_flag(1) TYPE c,
zowners(30) TYPE c,
zowners_value(30) TYPE c,
zdate_changed(8) TYPE n,
ztime_changed(6) TYPE n,
END OF ncrf.
*DATA: NCRF LIKE ZNCRFID OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF it_ruleid OCCURS 0,
zrule_id(10) TYPE c,
zowners(30) TYPE c,
zowners_value(30) TYPE c,
END OF it_ruleid.
*data: wa like ncrf occurs 0 with header line.
DATA: BEGIN OF itab OCCURS 0,
zncrf_id(15) TYPE c,
zncrf_l4_name(60) TYPE c,
z9gl_sla_flag(1) TYPE c,
zowners(30) TYPE c,
zowners_value(30) TYPE c,
zdate_changed(8) TYPE n,
ztime_changed(6) TYPE n,
END OF itab.
data: file(10) type c,
dates type date.
EMAIL DECLARATION
*CONSTANTS: c_subject LIKE sodocchgi1-obj_descr VALUE 'Subject',
*c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
*DATA: g_time TYPE char8,
*g_email(40) TYPE c,
*g_sent_all(1) TYPE c,
*g_doc_data LIKE sodocchgi1,
*g_error TYPE sy-subrc.
*DATA: i_message LIKE solisti1 OCCURS 0 WITH HEADER LINE,
*i_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
*i_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
*DATA: BEGIN OF mailid OCCURS 0,
zemail_id TYPE zrule_id-zemail_id,
END OF mailid.
*data: mailid like zrule_id occurs 0 with header line.
UPLOADING FLAT FILE TO INTERNAL TABLE NCRF
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\VAMSY\file.txt'
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = ncrf[]
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
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF sy-subrc EQ 0.
Checking internal table ncrf is empty then
*delete records from TABLE ZNCRF_ID ******************************
IF ncrf[] IS INITIAL.
MESSAGE i003(ZMSG2).
ELSE.
DELETE FROM zncrfid.
ENDIF.
*****Values are read from rule table and checking owner and owner_value
*from zrule_id table and inserted into ZNCRFID **************
SELECT * FROM zrule_id INTO CORRESPONDING FIELDS OF TABLE it_ruleid
WHERE zrule_id IN ('OWNER1', 'OWNER2').
append IT_RULEID.
LOOP AT ncrf WHERE z9gl_sla_flag EQ 'Y'.
READ TABLE it_ruleid WITH KEY zowners = ncrf-zowners
zowners_value = ncrf-zowners_value.
IF ncrf-zowners = it_ruleid-zowners AND ncrf-zowners_value =
it_ruleid-zowners_value AND ncrf-z9gl_sla_flag ='Y'.
itab-zncrf_id = ncrf-zncrf_id.
itab-zncrf_l4_name = ncrf-zncrf_l4_name.
itab-z9gl_sla_flag = ncrf-z9gl_sla_flag.
itab-zdate_changed = sy-datum.
itab-ztime_changed = sy-uzeit.
itab-zowners = it_ruleid-zowners.
itab-zowners_value = it_ruleid-zowners_value.
APPEND itab.
ENDIF.
ENDLOOP.
modify database table zncrfid FROM ITAB
LOOP AT itab.
WRITE:/ itab-zncrf_id, itab-zncrf_l4_name, itab-z9gl_sla_flag,
itab-zowners, itab-zowners_value, itab-zdate_changed,
itab-ztime_changed.
zncrfid-zncrf_id = itab-zncrf_id.
zncrfid-zncrf_l4_name = itab-zncrf_l4_name.
zncrfid-z9gl_sla_flag = itab-z9gl_sla_flag.
zncrfid-zowners = itab-zowners.
zncrfid-zowners_value = itab-zowners_value.
zncrfid-zdate_changed = itab-zdate_changed.
zncrfid-ztime_changed = itab-ztime_changed.
INSERT INTO zncrfid VALUES zncrfid.
ENDLOOP.
ENDIF.
ENDIF.
*CALL FUNCTION 'DATE_TO_DAY'
EXPORTING DATE = sy-datum
IMPORTING WEEKDAY = file.
**CHECKING FOR THE FIRST MONDAY OF THE MONTH.
dates = sy-datum.
shift dates by 6 places left.
if file CO 'monday' and dates < 7 and dates >= 1.
else.
message e004(zmsg2).
endif.
EMAIL SEND TO OWNERS LIST
**Fill the mail body in i_message.
get email id's from database into internal table et_mailid
Fill the document data.
*g_doc_data-doc_size = 1.
Populate the subject/generic message attributes
*g_doc_data-obj_langu = sy-langu.
*g_doc_data-obj_name = 'SAPRPT'.
*g_doc_data-obj_descr = c_subject .
*g_doc_data-sensitivty = 'F'.
Describe the body of the message
Information about structure of data tables
*CLEAR i_packing_list.
*REFRESH i_packing_list.
*i_packing_list-transf_bin = space.
*i_packing_list-head_start = 1.
*i_packing_list-head_num = 0.
*i_packing_list-body_start = 1.
*DESCRIBE TABLE i_message LINES i_packing_list-body_num.
*i_packing_list-doc_type = 'RAW'.
*APPEND i_packing_list.
Add the recipients email address
*LOOP AT mailid.
*CLEAR i_receivers.
*i_receivers-receiver = mailid-zemail_id.
*i_receivers-rec_type = 'U'.
*i_receivers-com_type = 'INT'.
*i_receivers-notif_del = 'X'.
*i_receivers-notif_ndel = 'X'.
*APPEND i_receivers.
*ENDLOOP.
Call the FM to post the message to SAPMAIL
*CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
*EXPORTING
*document_data = g_doc_data
*put_in_outbox = 'X'
*commit_work = 'X'
*IMPORTING
*sent_to_all = g_sent_all
*TABLES
*packing_list = i_packing_list
*contents_txt = i_message
*receivers = i_receivers
*EXCEPTIONS
*too_many_receivers = 1
*document_not_sent = 2
*document_type_not_exist = 3
*operation_no_authorization = 4
*parameter_error = 5
*x_error = 6
*enqueue_error = 7
*OTHERS = 8.
Store function module return code
*g_error = sy-subrc.
Get i_receivers return code
*LOOP AT i_receivers.
*ENDLOOP.
**Instructs mail send program for SAPCONNECT to send email(rsconn01)
*WAIT UP TO 2 SECONDS.
*IF g_error EQ 0.
*SUBMIT zgbl_sla_per WITH mode = 'INT'
*WITH output = 'X'
*AND RETURN.
REWARD IF FOUND USEFULL,
Cheers,
Chandru

Similar Messages

  • How to send image file through mail without   any attachment

    Plz tell  me how to send image file through mail without any attachment  ( i mean not converting  that image into pdf or any format )  i want to send that text or image  through mail .

    Hi Sandeep,
    I think you can setup the type of email in Shared office Settings in transaction S016.
    There is an option called <Preset document classes>
    You choose this pushbutton to branch to the maintenance screen for the document classes that are directly displayed to users in the Business Workplace for selection when they use the Create function. The name under which the documents are displayed can also be maintained.
    http://help.sap.com/saphelp_nw70/helpdata/en/6c/69c30f418d11d1896e0000e8322d00/content.htm
    Haven't tried it though.
    Regards,
    Siddhesh

  • Very urjent how to send report output in mail

    hi experts,
    how to send report output in mail which function module should i use wht parameters should i pass.
    thanks in addavnce,
    points to be awarded.

      CALL FUNCTION 'GET_PRINT_PARAMETERS'
           EXPORTING
                destination    = '026c'
                copies         = count
                list_name      = 'VATS_ASBUILT'
                list_text      = v_list
                immediately    = 'X'
                release        = 'X'
                new_list_id    = 'X'
                expiration     = days
                line_size      = 132
                line_count     = 65
                layout         = 'X_65_132'
    *            sap_cover_page = 'X'
    *            cover_page     = 'X'
                receiver       = 'SAP*'
                department     = 'VATS'
                no_dialog      = 'X'
           IMPORTING
                out_parameters = params
                valid          = valid.
      SUBMIT zppr_vats_asbuilt  WITH p_aufnr EQ v_aufnr
                   TO SAP-SPOOL WITHOUT SPOOL DYNPRO
                      SPOOL PARAMETERS params
                         AND RETURN.
      SELECT SINGLE rqident FROM tsp01 INTO l_spoolno
                         WHERE rqtitle = v_list .
    * convert report to PDF format
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = l_spoolno
                no_dialog                = 'X'
           TABLES
                pdf                      = l_ipdf
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        EXIT .
      ENDIF.
    Now comes the part to send the mail
      try.
    * -------- create persistent send request ------------------------
          send_request = cl_bcs=>create_persistent( ).
          clear document.
    * -------- create and set document with attachment ---------------
    * create document from internal table with text
          document = cl_document_bcs=>create_document(
          i_type = 'RAW'
          i_text = text
          i_length = '12'
          i_subject = '' ).
    *changing the content of the attachment
          binary_content[] = l_iobjbin[].
    *change the name of the PDF attachment
          concatenate 'Build ID' s_buildid_i 'Rev' v_buildid_rev
                              into i_att_sub separated by space.
    * add attachment to document
          call method document->add_attachment
            exporting
              i_attachment_type    = 'PDF'
              i_attachment_subject = i_att_sub
              i_att_content_hex    = binary_content.
    *setting the option to send an e-mail more than 50 characters
          call method send_request->set_message_subject
            exporting
              ip_subject = t_sub.
    * add document to send request
          call method send_request->set_document
            exporting
              i_document = document.
    * --------- set sender -------------------------------------------
    * note: this is necessary only if you want to set the sender
    * different from actual user (SY-UNAME). Otherwise sender is
    * set automatically with actual user.
          sender = cl_sapuser_bcs=>create( 'VATSUPPORT' ).
          call method send_request->set_sender
            exporting
              i_sender = sender.
    *Send the list based on receivers list obtained
          loop at l_ireclist.
            AD_SMTPADR = l_ireclist-receiver.
    * --------- add recipient (e-mail address) -----------------------
    * create recipient - please replace e-mail address !!!
          recipient = cl_cam_address_bcs=>create_internet_address(
          AD_SMTPADR ).
    * add recipient with its respective attributes to send request
          call method send_request->add_recipient
            exporting
              i_recipient = recipient
              i_express   = 'X'.
          ENDLOOP.
          call method send_request->set_status_attributes
            exporting
              i_requested_status = 'E'
              i_status_mail      = 'E'.
    * To send the mail immediately
          call method send_request->set_send_immediately( 'X' ).
    * ---------- send document ---------------------------------------
          call method send_request->send( ).
          commit work.

  • How to send sapmails to external mail systems

    Hi,
    how to send sapmails to external mail systems....
    like if we want to mail a purchase order from SAP System to *@yahaoo.com or @.com.
    TY.

    hi manish,
    u can do it.
    chk this .
    chk this code
    DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
    DATA: doc_chng LIKE sodocchgi1.
    *& Form f_send_mail
    text
    --> p1 text
    <-- p2 text
    FORM f_send_mail .
    *store the vendor name, vendor email id , employee name and employee
    *email id in the internal table int_crb
    Creation of the document to be sent
    CLEAR doc_chng.
    REFRESH objpack.
    REFRESH objhead.
    REFRESH reclist.
    REFRESH objtxt.
    File Name
    doc_chng-obj_name = 'SHIPMENT'.
    Mail Subject
    CONCATENATE 'Shipment Document No.' int_crb_mail-shipdocnum
    'Cleared.'
    INTO doc_chng-obj_descr SEPARATED BY ' '.
    Mail Contents
    objtxt-line = 'Hi,'.
    APPEND objtxt.
    objtxt-line = ' '.
    APPEND objtxt.
    CONCATENATE 'Shipment Document Number ' int_crb_mail-shipdocnum
    ' cleared for move.' INTO objtxt-line SEPARATED BY ' '.
    APPEND objtxt.
    objtxt-line = ' '.
    APPEND objtxt.
    CLEAR objtxt.
    objtxt-line = 'Regards '.
    APPEND objtxt.
    objtxt-line = ' '.
    APPEND objtxt.
    objtxt-line = 'SAP '.
    APPEND objtxt.
    CLEAR objtxt.
    APPEND objtxt.
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN(
    objtxt ).
    Creation of the entry for the compressed document
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'RAW'.
    APPEND objpack.
    Completing the recipient list
    target recipent
    CLEAR reclist.
    reclist-receiver = int_crb_mail-empperid. "employee email ID
    "wf_empperid.
    reclist-express = 'X'.
    reclist-rec_type = 'U'.
    APPEND reclist.
    copy recipents
    CLEAR reclist.
    reclist-receiver = int_crb_mail-smtp_addr."vendor email id
    reclist-express = 'X'.
    reclist-rec_type = 'U'.
    reclist-copy = 'X'.
    APPEND reclist.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = doc_chng
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    receivers = reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    operation_no_authorization = 4
    OTHERS = 99.
    COMMIT WORK.
    SUBMIT rsconn01
    WITH mode = 'INT'
    WITH output = ' '
    AND RETURN.
    ENDFORM. " f_send_mail
    for any clarifiaction pls mail me.
    pls reward points, if this helped u.
    regards,
    anversha.
    [email protected]

  • How to send data from internal table to the shared folder in ABAP

    Hi experts,
             My requirement is to transfer data from a file to shared folder. i just did reading data from a file to a internal table. Now i want to send this internal table data into a shared folder which is  "
    xxx\y\z....".
    I do not have any idea on how to send data from internal table to the shared folder path.
    can anybody please help me out how to do this?
    Thanks & Regards
    Sireesha.

    Where that folder is located, its on presentation server i.e. desktop or application server.
    If its on presentation server, use FM GUI_UPLOAD.
    If its on application server, then use DATASET functions. Have a look at below link.
    [File Handling in ABAP|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm]
    I hope it helps.
    Thanks,
    Vibha
    Please mark all the useful answers

  • Can't send or receive internal mail Outlook 2013/Exchange 2013

    Working on migrating from Exchange 2010 to 2013 .  When I move a mailbox to the 2013 DB I lose the ability to send or receive internal mail.  OWA works fine, but no internal.  If I move it back to 2010, everything runs perfect.  I have
    been chasing my tail and seem to be missing something.  Any suggestions?
    :Updated:
    Host record incorrect.

    Hi Doc, First of all I would recomend you to take a look to this link:
    http://technet.microsoft.com/en-US/exdeploy2013/Checklist?state=2419-W-AgAEAAAAQAAAAAEAAQAAAAA%7e
    It's very helpfull for migrations, take the time to review it, also, in your particulary case, I'd recommend you to redirect all the messaging throught the new Exchange 2013 CAS server, so in that case all the mails from outbound just get authenticated and
    then search for each mailbox.
    Your issue cames out because your moving the user to an isolate envioroment, maybe the send connectors aren't configured, have you installed the Domain Certificate? or maybe have you exported?
    Luis Antonio Navarrete Aranda Consultor Senior Akros Solutions Ecuador

  • How to send attachment mail in sap

    hi all,
    please guide me how to use function module named SO_NEW_DOCUMENT_ATT_SEND_API1.
    i have text files in internal table.
    please guide me how can i send files in my internal table as in attachment.

    Manish,
    Just copy paste the below code as given into a report only changing the email address of receipient to your email address to testing.
    That is line:
    lwa_reclist-receiver = '[email protected]'. " Email address of your receipient
    Then I think your SCOT is not configured for automatic execution hence once you have run your report go to transaction SCOT and press (Ctrl + F7) to start send process.
    A mail will be sent to your email address specified in the receipient list and a copy of it also placed in your SBWP Outbox.
    Let me know if you need further help, else reward neccessary points.
    Code
    *& Report  ZMFV_ROUGH_PAD
    REPORT  zmfv_rough_pad.
    DATA :
    li_attachment TYPE TABLE OF soli, " hold attachment contents
    li_pdf        TYPE TABLE OF tline, " hold data from spool in PDF format
    li_objpack    TYPE TABLE OF sopcklsti1, " hold email body, attachment details
    li_objtxt     TYPE TABLE OF solisti1, " hold message contents
    li_reclist    TYPE TABLE OF somlreci1. " hold email reciever details
    DATA :
    lwa_attachment    LIKE LINE OF li_attachment,
    lwa_pdf           LIKE LINE OF li_pdf,
    lwa_objpack       LIKE LINE OF li_objpack,
    lwa_objtxt        LIKE LINE OF li_objtxt,
    lwa_reclist       LIKE LINE OF li_reclist,
    lwa_document_data TYPE sodocchgi1. " hold document details like title, size etc.
    DATA :
    lv_sent_to_all     TYPE c, " flag to check if mail is sent to all
    l_att_lines        TYPE i, " hold number of lines in attachment table
    lv_spool_desc(68)  TYPE c. " hold description of spool
    CONSTANTS : lc_email_txt TYPE solisti1-line VALUE 'Find attached Payment Advice sent by this email.',
    lc_sensitivity TYPE sodocchgi1-sensitivty VALUE 'O',
    lc_raw         TYPE sopcklsti1-doc_type VALUE 'RAW',
    lc_pdf         TYPE sopcklsti1-doc_type VALUE 'PDF',
    lc_transf_bin  TYPE sopcklsti1-transf_bin VALUE 'X',
    lc_email       TYPE sopcklsti1-obj_name VALUE 'Email',
    lc_ext_id      TYPE somlreci1-rec_type VALUE 'U',
    lc_outbox      TYPE sonv-flag VALUE 'X',
    lc_obj_name    TYPE sodocchgi1-obj_name VALUE 'Email Test',
    lc_1           TYPE n VALUE '1',
    lc_0           TYPE n VALUE '0'.
    CLEAR: lwa_attachment,
    lwa_pdf,
    lwa_reclist,
    lwa_objtxt,
    lwa_objpack,
    lwa_document_data.
    REFRESH : li_attachment,
    li_pdf,
    li_reclist,
    li_objtxt,
    li_objpack.
    Build attachment table
    lwa_attachment-line = 'YOUR TEXT FROM INTERNAL TABLE LINES'.
    APPEND lwa_attachment TO li_attachment.
    Body of email
    CLEAR lwa_objtxt.
    MOVE lc_email_txt TO lwa_objtxt.
    APPEND lwa_objtxt TO li_objtxt.
    Title of the email
    lwa_document_data-obj_descr = 'Title of email'.
    lwa_document_data-sensitivty = lc_sensitivity.
    lwa_document_data-expiry_dat = sy-datum + 15.
    lwa_document_data-doc_size = STRLEN( lwa_objtxt ).
    lwa_document_data-obj_name = lc_obj_name.
    e-mail body
    CLEAR lwa_objpack.
    lwa_objpack-head_start = lc_1.
    lwa_objpack-head_num = lc_0.
    lwa_objpack-body_start = lc_1.
    lwa_objpack-body_num = lc_1.
    lwa_objpack-doc_type = lc_raw.
    lwa_objpack-doc_size = STRLEN( lwa_objtxt ).
    APPEND lwa_objpack TO li_objpack.
    For e-mail attachment
    DESCRIBE TABLE li_attachment LINES l_att_lines.
    CLEAR lwa_attachment.
    READ TABLE li_attachment INDEX l_att_lines INTO lwa_attachment.
    CLEAR lwa_objpack.
    lwa_objpack-transf_bin = lc_transf_bin.
    lwa_objpack-head_start = lc_1.
    lwa_objpack-head_num = lc_1.
    lwa_objpack-body_start = lc_1.
    lwa_objpack-body_num = l_att_lines.
    lwa_objpack-doc_type = lc_raw.
    lwa_objpack-obj_name = lc_email.
    lwa_objpack-obj_descr = lv_spool_desc.
    lwa_objpack-doc_size = ( 255 * ( l_att_lines - 1 ) ) + STRLEN( lwa_attachment-line ).
    APPEND lwa_objpack TO li_objpack.
    make recipient list
    CLEAR lwa_reclist.
    lwa_reclist-receiver = '[email protected]'. " Email address of your receipient
    lwa_reclist-rec_type = lc_ext_id. " To external email id
    lwa_reclist-COM_TYPE = 'INT'.     " Internet mail
    APPEND lwa_reclist TO li_reclist.
    send mail with attachment
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = lwa_document_data
        put_in_outbox              = lc_outbox
        commit_work                = 'X'
      IMPORTING
        sent_to_all                = lv_sent_to_all
      TABLES
        packing_list               = li_objpack
        contents_bin               = li_attachment
        contents_txt               = li_objtxt
        receivers                  = li_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.
      WRITE: 'Success'.
    ENDIF.

  • How to send incoming XML as mail-attachment

    Hi Experts,
    I have the following scenario: an incoming XML-file should be send as attachment of a mail. Now, I have defined incoming message with the structure of the xml-message and outgoing message as mail-package. In the message mapping I fill the nessesary mail-fields. In my receiver comm.channel (mailadapter) I checked "Use mail package" and "Keep attachment".
    Result is that the mail is created and send ok, but without attachment....what am I doing wrong here?
    Regards,
    William

    Hi JWD,
    You should configure the mail adapter with 'use the mail adpater' and 'keep attachments'.
    Create an XML file conform the XML structure provide by SAP
    The mail package should look like this:
    <?xml version="1.0" encoding="utf-8"?>
    <ns:MT_Mail_Sent xmlns:xi="http://sap.com/xi/XI/Mail/30">
    <xi:Mail>
    <Subject>Item</Subject>
    <From>MAIL ADDRESS</From>
    <To>MAIL ADRESS</To>
    <Content_Type>multipart/mixed; boundary="AaBb--984dfgeSSd3532"</Content_Type>
    <Content_Disposition>attachment</Content_Disposition>
    <Content>
    AaBb984dfgeSSd3532
    Content-Type: text/plain
    this is sample data.
    AaBb984dfgeSSd3532
    Content-Type: text/plain;name="CSV_data.csv"
    Order number;Item number;description<xsl:text> </xsl:text>
    <xsl:for-each select="Article_line">
    <xsl:value-of select="Ord_nmbr"/>;<xsl:value-of select="Item_nmbr"/>;<xsl:value-of select="Description<xsl:text>
    </xsl:text></xsl:for-each>
    AaBb984dfgeSSd3532
    Content-Type: text/plain;name="TXT_data.txt"
    Order number;Item number;description<xsl:text> </xsl:text>
    <xsl:for-each select="Article_line">
    <xsl:value-of select="Ord_nmbr"/>;<xsl:value-of select="Item_nmbr"/>;<xsl:value-of select="Description<xsl:text> </xsl:text></xsl:for-each>
    AaBb984dfgeSSd3532
    </Content>
    </xi:Mail>
    </ns:MT_Mail_Sent>
    In the above example you should have some content and 2 attachments (1 csv file and 1 txt file).
    After each break (AaBb984dfgeSSd3532) specify again the 'Content-Type'.
    *When you want to send a message payload as described, you have to set in the mail receiver channel the parameter Content Encoding to None and uncheck Keep Attachments.
    The last boundary AaBb984dfgeSSd3532 should be omitted, as the mail adapter sets that border itself (tested with SP16)*
    Reward points if this helps
    Regards
    Pragathi.

  • How to send table contents as mail attachment.

    Hi,
       I am showing data into webdynpro table by accessing database. Now i have to send these data through mail to different persons. How can i do it. I tried it by sending the table elements into excel files but i am facing some problems. can it be done through HTML files??
          Please give a solution to it.
          Thanks and Regards..
          Pankaj Kumar.

    Pankaj
    I am giving sample code here.
    Put this code in an action behind Send Mail button on your iview as an example.
    Also add external jar file mail.jar to your web dynpro project to achieve your objective.
         if(wdContext.currentContextElement().getTest()== null)
              IWDWindowInfo windowInfo1 = wdComponentAPI.getComponentInfo().findInWindows("EnterText");
              IWDWindow window1 =wdComponentAPI.getWindowManager().createWindow(windowInfo1,true);
              window1.open();
              window1.setWindowPosition(300,300);
              wdContext.currentContextElement().setEmptyText(window1);
         } else
              Properties props = new Properties();
              String host = "XXX.XXX.X.X"; /*ip address of mail server */
              props.put("mail.smtp.host", host);
              props.put("mail.smtp.port", "25");
              props.put("mail.smtp.auth","false");
         //     auth = new AuthenticationBean();
              Session session = Session.getInstance(props, null);
               MimeMessage  message = new MimeMessage (
              Session.getInstance ( props, null ) );
             Address toAddress = new InternetAddress();
              Address fromAddress = new InternetAddress();
              Address ccAddress = new InternetAddress();
              Address bccAddress = new InternetAddress();
                     //new window code
                   IWDWindowInfo windowInfo = wdComponentAPI.getComponentInfo().findInWindows("SuccessWindow");
                   IWDWindow window =wdComponentAPI.getWindowManager().createWindow(windowInfo,true);
                   window.open();
                   window.setWindowPosition(300,300);
                   wdContext.currentContextElement().setSuccess(window);
            try
                   MimeMultipart multipart = new MimeMultipart();
                   BodyPart messageBodyPart = new MimeBodyPart();
                     fromAddress = new InternetAddress(wdContext.currentContextElement().getFromEmail());
                   message.setFrom(fromAddress);
                   toAddress = new InternetAddress(wdContext.currentContextElement().getRfcEmail());
                   wdContext.currentContextElement().setErr(wdContext.currentContextElement().getRfcEmail());
                   message.setRecipient(Message.RecipientType.TO, toAddress);
                   message.setSubject(wdContext.currentContextElement().getMycontactDD());
                   messageBodyPart.setText("Message From :"" " wdThis.wdGetMailAppController().wdGetContext().currentContextElement().getName()"\r\n""\r\n"+wdContext.currentContextElement().getTest());
                   multipart.addBodyPart(messageBodyPart);
                   message.setContent(multipart);
                   Transport.send(message);
                 catch (AddressException e)
                             wdComponentAPI.getMessageManager().reportWarning(e. getLocalizedMessage());
                              e.printStackTrace();
                 catch (SendFailedException e)
                        wdComponentAPI.getMessageManager().reportWarning(e. getLocalizedMessage());
                         e.printStackTrace();
                 catch (MessagingException e)
                         wdComponentAPI.getMessageManager().reportWarning( e.getLocalizedMessage());
                         e.printStackTrace();
    Please award points if this helps as this will give you a hint for sending mails.

  • How to send smart form as mail?

    Hello everybody,
    I have used the following code to send a smartform in PDF format through email.
    I m able to view the contents of the mail in SAP Bussiness Workplace but UNABLE TO TRANSFER THE MAIL to an INTERNET ID (like gmail id or yahoo id).
    Can anybody suggest me about what might have gone wrong?
    Helpful answers will surely be rewarded.
    code
      DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
      i_tline TYPE TABLE OF tline WITH HEADER LINE,
      i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
      i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
      i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
      i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
      wa_objhead TYPE soli_tab,
      w_ctrlop TYPE ssfctrlop,
      w_compop TYPE ssfcompop,
      w_return TYPE ssfcrescl,
      wa_doc_chng TYPE sodocchgi1,
      w_data TYPE sodocchgi1,
      wa_buffer TYPE string,"To convert from 132 to 255
    Variables declarations
    *v_form_name TYPE rs38l_fnam, " L_FM_NAME
      v_len_in LIKE sood-objlen,
      v_len_out LIKE sood-objlen,
      v_len_outn TYPE i,
      v_lines_txt TYPE i,
      v_lines_bin TYPE i.
      DATA: l_fm_name TYPE rs38l_fnam.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname                 = p_l_formname
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
       IMPORTING
         fm_name                   = l_fm_name
       EXCEPTIONS
         no_form                  = 1
         no_function_module       = 2
         OTHERS                   = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      IF g_it3 = 'M'.
        g_it3 = 'Mr'.
      ENDIF.
      IF g_it3 = 'F'.
        g_it3 = 'Ms'.
      ENDIF.
      CALL FUNCTION l_fm_name
        EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
      CONTROL_PARAMETERS         =
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
      OUTPUT_OPTIONS             =
      USER_SETTINGS              = 'X'
          it                         =     g_it
          it1                        =     g_it1
          it3                        =     g_it3
          it4                        =     g_it4
          it5                        =     g_it5
          it6                        =     g_it6
          it7                        =     g_it7
          it8                        =     g_it8
          it10                       =     g_it10
          it14                       =     g_it14
          it15                       =     g_it15
          it36                       =     g_it36
          it18                       =     g_it18
          it37                       =     g_it37
          it19                       =     g_it19
          it9                        =     g_it9
          it11                       =     g_it11
          it13                       =     g_it13
          it39                       =     g_it39
          it40                       =     g_it40
          it20                       =      g_it20
          it21                       =      g_it21
          it22                       =      g_it22
          it23                       =      g_it23
          it25                       =      g_it25
          it26                       =      g_it26
          it27                       =      g_it27
          it28                       =      g_it28
          it29                       =      g_it29
          it30                       =      g_it30
          it31                       =      g_it31
          it32                       =      g_it32
          it33                       =      g_it33
          total                      =      g_total
          it34                       =      g_it34
          it35                       =      g_it35
          it2                        =     pa0006-begda
          it12                       =     pa0001-begda
          it16                       =     pa0015-begda
          it17                       =     pa0001-endda
          it24                       =      pa0002-endda
          it38                       =     pa0002-begda
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
        EXCEPTIONS
          formatting_error           = 1
          internal_error             = 2
          send_error                 = 3
          user_canceled              = 4
          OTHERS                     = 5
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    g_semail = 'X'.
    IF g_semail = 'X'.
        w_ctrlop-getotf = 'X'.
        w_ctrlop-no_dialog = 'X'.
        w_compop-tdnoprev = 'X'.
        CALL FUNCTION l_fm_name
          EXPORTING
            control_parameters = w_ctrlop
            output_options     = w_compop
            user_settings      = 'X'
          IMPORTING
            job_output_info    = w_return
          EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 4
            OTHERS             = 5.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        i_otf[] = w_return-otfdata[].
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = 'PDF'
            max_linewidth         = 132
          IMPORTING
            bin_filesize          = v_len_in
          TABLES
           otf                   = i_otf
            otf                   = i_otf
           lines                 = i_tline
            lines                 = i_tline
          EXCEPTIONS
            err_max_linewidth     = 1
            err_format            = 2
            err_conv_not_possible = 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.
    *convert PDF from 132 to 255
        LOOP AT i_tline.
    *Replacing space by '~'.
          TRANSLATE i_tline USING '~'.
          CONCATENATE wa_buffer i_tline INTO wa_buffer.
        ENDLOOP.
    *Repalacing '~' by space.
        TRANSLATE wa_buffer USING '~'.
        DO.
          i_record = wa_buffer.
    *Appending 255 characters as a record.
          APPEND i_record.
          SHIFT wa_buffer LEFT BY 255 PLACES.
          IF wa_buffer IS INITIAL.
            EXIT.
          ENDIF.
        ENDDO.
    Attachment
        REFRESH:
        i_reclist,
        i_objtxt,
        i_objbin,
        i_objpack.
        CLEAR wa_objhead.
    *Object with PDF.
        i_objbin[] = i_record[].
        DESCRIBE TABLE i_objbin LINES v_lines_bin.
    Create Message Body
    Title and Description
    *Object with main text of the mail.
        i_objtxt = 'Find attached the output of the smartform'.
        APPEND i_objtxt.
        i_objtxt = 'Regards'.
        APPEND i_objtxt.
        i_objtxt = 'Lokesh'.
        APPEND i_objtxt.
        DESCRIBE TABLE i_objtxt LINES v_lines_txt.
       READ TABLE i_objtxt INDEX v_lines_txt.
    *Document information.
        wa_doc_chng-obj_name = 'Offer Letter'.
        wa_doc_chng-expiry_dat = sy-datum + 10.
        wa_doc_chng-obj_descr = 'Offer Letter'.
        wa_doc_chng-sensitivty = 'F'.
        wa_doc_chng-doc_size = v_lines_txt * 255.
    Main Text
    *Pack to main body as RAW.
    *Object to be transported not in binary form.
       wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
        CLEAR i_objpack-transf_bin.
        i_objpack-head_start = 1.
        i_objpack-head_num = 0.
        i_objpack-body_start = 1.
        i_objpack-body_num = v_lines_txt.
        i_objpack-doc_type = 'RAW'.
        APPEND i_objpack.
    Attachment
    (pdf-Attachment)
    *Packing as PDF
        i_objpack-transf_bin = 'X'.
        i_objpack-head_start = 1.
        i_objpack-head_num = 1.
        i_objpack-body_start = 1.
    Länge des Attachment ermitteln
       DESCRIBE TABLE i_objbin LINES v_lines_bin.
       READ TABLE i_objbin INDEX v_lines_bin.
        i_objpack-doc_size = v_lines_bin * 255 .
        i_objpack-body_num = v_lines_bin.
        i_objpack-doc_type = 'PDF'.
        i_objpack-obj_name = 'smart'.
        i_objpack-obj_descr = 'test'.
        APPEND i_objpack.
        CLEAR i_reclist.
        i_reclist-receiver = '[email protected]'.
        i_reclist-express = 'X'.
        i_reclist-rec_type = 'U'.
        APPEND i_reclist.
    *CALL FUNCTION 'LXE_SEND_MAIL_ATTMNT'
    EXPORTING
       description                =
      SENSITIVITY                = 'O'
      IN_OUTBOX                  = ' '
    tables
       receivers                  =
       document_text              =
      DOCUMENT_ATTMNT            =
      DOCUMENT_ATTMNT_ATTR       =
    EXCEPTIONS
      TOO_MANY_RECEIVERS         = 1
      DOCUMENT_NOT_SENT          = 2
      NO_AUTHORIZATION           = 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.
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data              = wa_doc_chng
            put_in_outbox              = 'X'
          TABLES
            packing_list               = i_objpack
            object_header              = wa_objhead
            contents_bin               = i_objbin
            contents_txt               = i_objtxt
            receivers                  = i_reclist
          EXCEPTIONS
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5
            x_error                    = 6
            enqueue_error              = 7
            OTHERS                     = 8.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ELSE.
          MESSAGE 'success' TYPE 'I'.
        ENDIF.
    ENDIF.
    ENDFORM.                    " GET_OFFER_LETTER

    Here is the code to send the Smartform to mail as PDF attachment.
    *& Report ZTEST_PDF_MAIL
    REPORT ZTEST_PDF_MAIL.
    Internal Table declarations
    DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
    I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
    I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    WA_OBJHEAD TYPE SOLI_TAB,
    W_CTRLOP TYPE SSFCTRLOP,
    W_COMPOP TYPE SSFCOMPOP,
    W_RETURN TYPE SSFCRESCL,
    WA_DOC_CHNG TYPE SODOCCHGI1,
    W_DATA TYPE SODOCCHGI1,
    WA_BUFFER TYPE STRING, "To convert from 132 to 255
    Variables declarations
    V_FORM_NAME TYPE RS38L_FNAM,
    V_LEN_IN LIKE SOOD-OBJLEN,
    V_LEN_OUT LIKE SOOD-OBJLEN,
    V_LEN_OUTN TYPE I,
    V_LINES_TXT TYPE I,
    V_LINES_BIN TYPE I.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    FORMNAME = 'ZTEST'
    IMPORTING
    FM_NAME = V_FORM_NAME
    EXCEPTIONS
    NO_FORM = 1
    NO_FUNCTION_MODULE = 2
    OTHERS = 3.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    W_CTRLOP-GETOTF = 'X'.
    W_CTRLOP-NO_DIALOG = 'X'.
    W_COMPOP-TDNOPREV = 'X'.
    CALL FUNCTION V_FORM_NAME
    EXPORTING
    CONTROL_PARAMETERS = W_CTRLOP
    OUTPUT_OPTIONS = W_COMPOP
    USER_SETTINGS = 'X'
    IMPORTING
    JOB_OUTPUT_INFO = W_RETURN
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    I_OTF[] = W_RETURN-OTFDATA[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    MAX_LINEWIDTH = 132
    IMPORTING
    BIN_FILESIZE = V_LEN_IN
    TABLES
    OTF = I_OTF
    LINES = I_TLINE
    EXCEPTIONS
    ERR_MAX_LINEWIDTH = 1
    ERR_FORMAT = 2
    ERR_CONV_NOT_POSSIBLE = 3
    OTHERS = 4.
    IF SY-SUBRC <> 0.
    ENDIF.
    LOOP AT I_TLINE.
    TRANSLATE I_TLINE USING '~'.
    CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    DO.
    I_RECORD = WA_BUFFER.
    APPEND I_RECORD.
    SHIFT WA_BUFFER LEFT BY 255 PLACES.
    IF WA_BUFFER IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    Attachment
    REFRESH: I_RECLIST,
    I_OBJTXT,
    I_OBJBIN,
    I_OBJPACK.
    CLEAR WA_OBJHEAD.
    I_OBJBIN[] = I_RECORD[].
    Create Message Body Title and Description
    I_OBJTXT = 'test with pdf-Attachment!'.
    APPEND I_OBJTXT.
    DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
    READ TABLE I_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
    Main Text
    CLEAR I_OBJPACK-TRANSF_BIN.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    I_OBJPACK-BODY_NUM = V_LINES_TXT.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND I_OBJPACK.
    Attachment (pdf-Attachment)
    I_OBJPACK-TRANSF_BIN = 'X'.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
    READ TABLE I_OBJBIN INDEX V_LINES_BIN.
    I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    I_OBJPACK-BODY_NUM = V_LINES_BIN.
    I_OBJPACK-DOC_TYPE = 'PDF'.
    I_OBJPACK-OBJ_NAME = 'smart'.
    I_OBJPACK-OBJ_DESCR = 'test'.
    APPEND I_OBJPACK.
    CLEAR I_RECLIST.
    I_RECLIST-RECEIVER = '[email protected]'.
    I_RECLIST-REC_TYPE = 'U'.
    APPEND I_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    COMMIT_WORK = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8.
    IF SY-SUBRC <> 0.
    WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
    WRITE:/ 'Mail sent'.
    ENDIF.
    If you want to send some text as Body of the Mail then follow this once
    when u r callin the FM'SO_NEW_DOCUMENT_ATT_SEND_API1'.. points to remember
    1.u have to pass the body of content in table CONTENTS_TXT(ia m using I_OBJBIN) (each line a record) then. suppose i have appended 11 records to the table CONTENTS_TXT .
    2.PACKING_LIST(iam usign I_OBJPACK) table u ahve to append a redord as follows
    I_OBJPACK-TRANSF_BIN = ' '.
    I_OBJPACK-HEAD_START = 000000000000001.
    I_OBJPACK-HEAD_NUM = 000000000000001.
    I_OBJPACK-BODY_START = 000000000000002
    I_OBJPACK-BODY_NUM = 000000000000010.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    append I_OBJPACK-.
    by the above code system treat the first line in table I_OBJBIN as header and the 2nd line to 10 lines tread as body.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8.
    regards,
    srinivas

  • How to send html newsletter via Mail app

    I want crystal and clear instruction as all the ones I have found either old fashioned and not relevant or skip that interesting part.
    I have already done html page (newsletter). Now I want to transform it somehow and send via Mail app so my contacts could receive it as html newsletter. If I need to attach txt message please add it to the instruction. I need complete how to send html newsletter.

    alabanco wrote:
    thanks. Now we've got to the most interesting part and intriguing one. Why should I upload html page to the server. I do understand uploading the images to server which will be used as links in my html mail. But why and how should I store that page in my server if I have CMS post instead from which I used pictures as links. SHould I create yet another type of post in CMS that is my html newsletter? That's not cool. What is the industry standard approach for that?
    By the way Mail.app uses that baby design templates for your messages. Why don't we have an option to delete all these creepy childish templates and store solid bold corporate style templates for newsletters and send it somehow? Or will it just attach the images to the message then? If so then it is not what I want and it is really depressing.
    The industry convention/"standard" is not to use html in email. Wheteher or not your html newsletter displays as you intended is at the mercy of the recipient and their email client settings.
    If you want to preserve your html layout and styles, save your newsletter as a pdf document and attach the pdf document to your email. Or, as already suggested, use a web server to serve your html newsletter.

  • How to send files to others mail id when executing the program

    Hi all,
    I am getting text file from application server and i am sending total text file data into my internal table.
    I am checking this internal table data especially material number and customer number with data base tables mara and kna1.If the matnr and kunnr are existing in database successfully means then only i am creating the sales orders for that text file data.if any record out of 10 records is not success means i am not creating sales orders for total text file data.
    My error log file as
    file name,date time,total no of records,error record no,error description.
    one more text file as
    file name,date time,total no of records,succesful records , error records.
    I am getting these all data into my one more internal table.
    I am appending all data into my internal table.
    so i want retrieve only last row of data from that internal table.pls guide me how to get last row from the internal table.
    these text files i have to send to my user mail id directly when i am executing the program.
    any one knows the any function modules to send that text files to perticular mails.pls send the FM's to me.
    Regards,
    lokesh.

    hi
    good
    go through this report,hope help you to solve your problem
    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
    thanks
    mrutyun^

  • How to: Send any document using mail via "Right click"

    Hello-
    Does anyone know how to send a document, whether it is a Word, Eccel, Pages doc, etc. via a "Right Click" or similiar key stroke as we can on a WinPC? I am certain it is possible, and the closest commandIi have found is the "Services:Mail" drop down which is seemingly useless (i.e. I do not know how to make use of it). Any suggestions are appreciated. Thx
    MacBookPro 15"   Mac OS X (10.4.6)  

    thexr6,
    Welcome to Apple Discussions.
    Try this if you want to add an attachment to a new mail message:
    1. Open Automator.
    2. In the Library column, click on Mail.
    3. In the Action column, double click on New Mail Message.
    3. In the Action column, double click on Add Attachments to Front Message.
    4. In Automator>File>Save As Plug-In...>Save Plug-in As: (Type your desired name here) Plug-in for: Finder>(Save)
    Right click on the file you wish to attach and select Automator>(your desired name).
    If you know where you actually want to send the message, enter the specific information required in step 3, and add/select "Send Outgoing Messages" after step 3.
    ;~)

  • SRM-- XI -- generate cXML EPO, how to send attached xls with xml ?

    Hi,
    We have to use XI to generate  E-  Purchase Order  and send it to  supplier in  cXML format.
    The flow is :--
    We have SRM> IDOC> XI--> cXML EPO
    I have couple of questions?
    1) Can I have some document where  this kind of scenarios  implemented?
    2) Can we send attachment (.xls file)  with the cXML file to external system., where  this attachment is coming  from  SRM.
    3) Can XI receive the attachment with the iDoc and send as is to the supplier?
    4) How  can we convert cXML 1.2 standard format as output?
    5) Which adapter can be used and receiver side  to publish the cXML format EPO?
    6)  What else we need to do to configure SRM to XI ?
    7)  how we make cXML 1.2 standard format  or  define data type?
    Please help me to understand  this, your inputs are appreciable? if  you  have any docs   then please mail me at [email protected]
    Thanks & regards
    Ram Singhal

    Hi Ram,
    Info about cXML
    http://en.wikipedia.org/wiki/CXML
    Info about attachments in cXML
    http://edocs.bea.com/wli/docs70/cxml/api.htm
    example of an order in cXML with attachment
    http://www.wmusers.com/wmusers/messages/117/AribaOrderwithAttachment-124618.txt
    I hope this help you.
    Bye.

  • How to send attachment(file) in javamail via JSP ?

    Dear Friends,
    Please guide me for :
    (1) my e-mail client is using JSP. So, hoW to send file-attachments via jsp ?
    Please specify example for attaching file(s) to a message object in JSP ( and only in JSP ).
    I have used HTML <input type="file" .... > control , but don't know how to bring that file to the jsp file and then attach it to the message object.
    Thank u.

    I wouldn't recommend using JSP to do that. I would use a servlet instead. Then you are just writing Java code, and to answer your two questions you need to learn about JavaMail (1) and get some already-written classes to do file uploads such as this one: http://www.servlets.com/cos/index.html (2).

Maybe you are looking for