Pdf send as email

hai gurus,
i am sending pdf via email its working fine
but the problem is pdf file is not opened
it showing an error
plz help me .
thanks in advance
anji

Moderator message: please search for available information/documentation before asking, provide more technical details about errors when posting again.
Your previous post got locked... how is this one going to be different?

Similar Messages

  • Exporting activity data as a PDF / sending as email from within package

    Hello,
    We are currently developing an E-learning package which involves the learners building up a check list on an "ipad" as they go through the course, which we would like them to then be able to save at the end of the course so they can review it later.
    We've managed to implement a print function, however we really need them to be able to save this data in some way.  Does any one know how we could push this data back to the LMS so it can somehow be downloaded and saved (in a good, branded format) or even better how we could make it into a PDF so it can be saved from with in the SCORM package or even in some way emailed.
    Any help would be much appreciated.
    Sam

    hi
    The funnier part is that
    u can actually type in the sender's email id irrespective of the mail host used
    Like @hotmail.com,@yahoo.com etc.
    The receiver will get the mails from the email id that u wrote .
    The problem u r facing is becoz of the incorrect mail host server ip address
    Try to get in touch with the network admin for the mail server ip address
    other way is
    get the name it would be like
    smtp.domain name .
    hope that helps

  • Smartform PDF sending as email

    Hi,
    I had a requirement like sending smartform o/p as PDF to multiple email-id's.
    I had used the FM's CONVERT_OTF and SO_NEW_DOCUMENT_ATT_SEND_API1 Function module's.
    Now I am able to receive the emails but unable to open the PDF document It is saying that the PDF was not decoded properly. Kindly help me out. I had also tried it using the GUI_DOWNLOAD after the CONVERT_OTF Function module. and was able to open the PDF format.
    Kindly help me out.
    Thanks & Regards,
    Sridhar.

    Compare your part of code with the below given code.
    *& Report YSSN_SIMPLE_SMARTFORM *
    report zhr_bhaskar_pdf_to_email message-id zmsg.
    parameters: p_vbeln type vbak-vbeln default '35'.
    data: it_items type table of vbap,
    v_fm_name type rs38l_fnam,
    v_tot_lines type i,
    v_sy_tabix type i,
    output_data type ssfcrescl. " To hold Output information
    constants:
    c_sep type c value '-', " Value -
    c_x type c value 'X', " Value X
    c_space type c value ' '. " Space
    *****MAIL START
    include .
    data: g_mail_rec_obj type swotobjid,
    g_mail_sen_obj type swotobjid,
    g_mail_app_obj type swotobjid,
    g_cont_par type ssfctrlop,
    folder type swc_object,
    begin of sofmfol_key,
    foldertype like sofm-foltp,
    folderyear like sofm-folyr,
    foldernumber like sofm-folno,
    type like sofm-doctp,
    year like sofm-docyr,
    number like sofm-docno,
    forwarder like soub-usrnam,
    end of sofmfol_key,
    bor_key like swotobjid-objkey,
    g_mail TYPE ppfdmailad VALUE '[email protected]',
    g_mail type so_name value '[email protected]',
    g_mail TYPE ppfdmailad VALUE '[email protected]' ,
    g_mail TYPE ppfdmailad VALUE '[email protected]' ,
    g_rectype type so_escape value 'U'. " 'B'.
    data: job_output_info type ssfcrescl,
    hotfdata like itcoo occurs 1 with header line,
    htline like tline occurs 1 with header line,
    x_objcont like soli occurs 1 with header line,
    ld_packing_list like soxpl occurs 1 with header line,
    x_object_hd_change like sood1 occurs 1 with header line,
    x_objhead like soli occurs 1 with header line,
    x_receivers like soos1 occurs 1 with header line,
    format_pdf(10) value 'PDF',
    doc_size(12) type c,
    hltlines type i,
    htabix like sy-tabix,
    fle1(2) type p,
    fle2(2) type p,
    off1 type p,
    hfeld(500) type c.
    tables: soud.
    *****MAIL END
    select *
    into table it_items
    from vbap
    where vbeln = p_vbeln.
    if it_items[] is initial.
    exit.
    endif.
    perform call_smartform.
    *& Form call_smartform
    text
    --> p1 text
    <-- p2 text
    form call_smartform .
    *DATA: lx_control_parameters TYPE SSFCTRLOP,
    lx_OUTPUT_OPTIONS type SSFCOMPOP.
    lx_OUTPUT_OPTIONS-TDIMMED = ' '.
    lx_OUTPUT_OPTIONS-TDfinal = 'X'.
    lx_OUTPUT_OPTIONS-TDDELETE = 'X'.
    lx_CONTROL_PARAMETERS-NO_CLOSE = 'X'.
    lx_CONTROL_PARAMETERS-NO_OPEN = ' '.
    data: x_ssfcompop type ssfcompop,
    x_ssfctrlop like ssfctrlop,
    x_ssfcrescl type ssfcrescl.
    **MAIL
    g_cont_par-langu = sy-langu.
    g_cont_par-no_dialog = 'X'.
    g_cont_par-getotf = 'X'.
    g_cont_par-device = 'MAIL'.
    Get BOR-Objects for Recipient, Sender und Applikation
    perform mail_recipient_object changing g_mail_rec_obj.
    perform mail_sender_object changing g_mail_sen_obj.
    perform mail_appl_object changing g_mail_app_obj.
    **MAIL
    *--Internal table is having more than 1 record
    if v_tot_lines gt 1.
    if v_sy_tabix = 1.
    *--For first record of table
    x_ssfctrlop-no_open = c_space.
    x_ssfctrlop-no_close = c_x.
    elseif v_sy_tabix = v_tot_lines.
    *--For last record of table
    x_ssfctrlop-no_open = c_x.
    x_ssfctrlop-no_close = c_space.
    else.
    x_ssfctrlop-no_open = c_x.
    x_ssfctrlop-no_close = c_x.
    endif.
    endif.
    IF r_previ = c_x.
    x_ssfctrlop-preview = c_x.
    x_ssfctrlop-getotf = c_x.
    ENDIF.
    call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
    formname = 'YSSN_SMARTFORM'
    VARIANT = ' '
    DIRECT_CALL = ' '
    importing
    fm_name = v_fm_name
    EXCEPTIONS
    NO_FORM = 1
    NO_FUNCTION_MODULE = 2
    OTHERS = 3
    if sy-subrc <> 0.
    message i000 with 'Smart form module name failure'.
    exit.
    endif.
    CALL FUNCTION '/1BCDWB/SF00000199'
    call function v_fm_name
    exporting
    ARCHIVE_INDEX =
    ARCHIVE_INDEX_TAB =
    ARCHIVE_PARAMETERS =
    control_parameters = g_cont_par
    mail_appl_obj = g_mail_app_obj
    mail_recipient = g_mail_rec_obj
    mail_sender = g_mail_sen_obj
    OUTPUT_OPTIONS = lx_OUTPUT_OPTIONS
    USER_SETTINGS = 'X'
    t_vbap = it_items
    IMPORTING
    DOCUMENT_OUTPUT_INFO =
    job_output_info = job_output_info
    JOB_OUTPUT_OPTIONS =
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5
    perform send_pdf_mail.
    endform. " call_smartform
    *& Form send_pdf_mail
    text
    --> p1 text
    <-- p2 text
    form send_pdf_mail .
    data ld_binfile type xstring.
    pdf_table type rcl_bag_tline,
    data: ld_originator like soos1-recextnam.
    convert form
    loop at job_output_info-otfdata into hotfdata.
    append hotfdata.
    endloop.
    call function 'CONVERT_OTF'
    exporting
    format = format_pdf
    max_linewidth = 132
    importing
    bin_filesize = doc_size
    bin_file = ld_binfile
    tables
    otf = output_data-otfdata
    lines = htline
    exceptions
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    others = 4.
    *-Itab 134 Zeichen nach 255 Zeichen überführen
    describe table htline lines hltlines.
    describe field htline length fle1 in character mode.
    describe field x_objcont length fle2 in character mode.
    loop at htline.
    htabix = sy-tabix.
    move htline to hfeld+off1.
    if htabix = hltlines.
    fle1 = strlen( htline ).
    endif.
    off1 = off1 + fle1.
    if off1 ge fle2.
    clear x_objcont.
    x_objcont = hfeld(fle2).
    append x_objcont.
    shift hfeld by fle2 places.
    off1 = off1 - fle2.
    endif.
    if htabix = hltlines.
    if off1 gt 0.
    clear x_objcont.
    x_objcont = hfeld(off1).
    append x_objcont.
    endif.
    endif.
    endloop.
    x_object_hd_change-objnam = 'EMAIL'.
    x_object_hd_change-objdes = 'Smart Form'.
    x_object_hd_change-objla = sy-langu.
    x_object_hd_change-objsns = 'O'.
    x_object_hd_change-objlen = doc_size.
    x_object_hd_change-file_ext = 'TXT'.
    ld_packing_list-transf_bin = 'X'.
    ld_packing_list-head_start = 1.
    ld_packing_list-head_num = 0.
    ld_packing_list-body_start = 1.
    describe table x_objcont lines ld_packing_list-body_num.
    ld_packing_list-objtp = 'EXT'.
    ld_packing_list-objdes = 'Smart Form'.
    ld_packing_list-objla = sy-langu.
    ld_packing_list-objlen = doc_size.
    ld_packing_list-file_ext = 'PDF'.
    append ld_packing_list.
    x_receivers-recextnam = g_mail.
    x_receivers-recesc = 'E'.
    x_receivers-sndart = 'INT'.
    append x_receivers.
    ld_originator = '[email protected]'.
    ld_originator = FSABE-USRNAM.
    call function 'SO_OBJECT_SEND'
    exporting
    object_hd_change = x_object_hd_change
    object_type = 'RAW'
    originator_type = 'B' "Einfügen
    originator = ld_originator "Einfügen
    tables
    objcont = ld_text
    receivers = x_receivers
    packing_list = ld_packing_list
    att_cont = x_objcont
    att_head = x_objhead
    exceptions
    active_user_not_exist = 1
    communication_failure = 2
    component_not_available = 3
    folder_not_exist = 4
    folder_no_authorization = 5
    forwarder_not_exist = 6
    note_not_exist = 7
    object_not_exist = 8
    object_not_sent = 9
    object_no_authorization = 10
    object_type_not_exist = 11
    operation_no_authorization = 12
    owner_not_exist = 13
    parameter_error = 14
    substitute_not_active = 15
    substitute_not_defined = 16
    system_failure = 17
    too_much_receivers = 18
    user_not_exist = 19
    x_error = 20
    others = 21.
    endform. " send_pdf_mail
    *& Form mail_sender_object
    text
    <--P_G_MAIL_SEN_OBJ text
    form mail_sender_object changing p_mail_sen_obj.
    call function 'CREATE_SENDER_OBJECT_PPF'
    exporting
    ip_sender = sy-uname
    importing
    ep_sender_id = p_mail_sen_obj
    exceptions
    invalid_sender = 1
    others = 2.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    endform. " mail_sender_object
    *& Form mail_appl_object
    text
    <--P_G_MAIL_APP_OBJ text
    form mail_appl_object changing p_mail_app_obj.
    SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
    ENDSELECT.
    IF sy-subrc NE 0.
    call function 'SO_USER_AUTOMATIC_INSERT'
    exporting
    sapname = sy-uname
    exceptions
    no_insert = 1
    sap_name_exist = 2
    x_error = 3
    others = 4.
    if sy-subrc ne 0.
    clear soud.
    else.
    select * from soud where sapnam like sy-uname and deleted = ' '.
    endselect.
    endif.
    ENDIF.
    clear sofmfol_key.
    sofmfol_key-type = 'FOL'.
    sofmfol_key-year = soud-inbyr.
    sofmfol_key-number = soud-inbno.
    bor_key = sofmfol_key.
    if not bor_key is initial.
    swc_create_object folder 'SOFMFOL' bor_key.
    if sy-subrc = 0.
    swc_object_to_persistent folder p_mail_app_obj.
    if sy-subrc ne 0.
    clear p_mail_app_obj.
    endif.
    endif.
    else.
    clear p_mail_app_obj.
    endif.
    endform. " mail_appl_object
    *& Form mail_recipient_object
    text
    <--P_G_MAIL_REC_OBJ text
    form mail_recipient_object changing p_mail_rec_obj.
    call function 'CREATE_RECIPIENT_OBJ_PPF'
    exporting
    IP_COUNTRY =
    IP_FAXNO =
    ip_mailaddr = g_mail
    ip_type_id = g_rectype " 'U'
    importing
    ep_recipient_id = p_mail_rec_obj
    EP_ADDRESS =
    ET_RECIPIENT =
    exceptions
    invalid_recipient = 1
    others = 2.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    endform. " mail_recipient_object

  • Background Submit to Spool,  convert spool to PDF send via email

    I am calling an ABAP in the background. this abap makes use of a custom table as the main driver ie on each change of vendor within this custom table I want to create a spool and email the spool - the spool is suppossed to be created via a submit RMCB0300  with screen selection to to sap-spool and return. I then want the program to take the spool convert it to PDF and email.
    Problems I am encountering:
    1. writing to the spool via background ABAP  as follows
       submit RMCB0300 with selection-table rspar
                  to sap-spool
                  spool parameters %_print
                 archive parameters %_archive
                 without spool dynpro and return.
    Doesn't appear to be creating the spool - rspar is populated.
    2. Best way to retrieve the correct spool number.
    3. how to successfully convert PDF output after CONVERT_ABAPSPOOLJOB_2_PDF for email attachment - if this returns IT_PDF_OUTPUT.
    is this the best way to do it:
    Loop at IT_PDF_OUTPUT
          Translate IT_PDF_OUTPUT using ' ~'.
          concatenate gd_buffer it_pdf_output into gd_buffer
        endloop.
       translate gd_buffer using '~ '
    Do it_mess_att = gd_buffer.
         append it_mess_att.
         shift gd_buffer left by 255 places
         if gd_buffer is initial
           exit.
         endif.
    enddo.
    Thanks
    Mark
    Edited by: Matt on Apr 2, 2009 11:03 AM - amended title with formatting problems.

    Please find the code for converting SPool to pdf and sending mail
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
         EXPORTING
           SRC_SPOOLID              = LV_MI_RQIDENT
           NO_DIALOG                = 'X'
           DST_DEVICE               = LV_PRINT_PARMS-PDEST
         IMPORTING
           PDF_BYTECOUNT            = LV_BYTECOUNT
           PDF_SPOOLID              = LV_RQIDENT
         TABLES
           PDF                      = LT_MTAB_PDF
         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.
       ENDIF.
       LOOP AT LT_MTAB_PDF INTO LWA_MTAB_PDF.
         TRANSLATE LWA_MTAB_PDF USING ' ~'.
         CONCATENATE LV_GD_BUFFER LWA_MTAB_PDF INTO LV_GD_BUFFER.
         CLEAR LWA_MTAB_PDF.
       ENDLOOP.
       TRANSLATE LV_GD_BUFFER USING '~ '.
       DO.
         LWA_MESS_ATT = LV_GD_BUFFER.
         APPEND LWA_MESS_ATT TO LT_MESS_ATT.
         CLEAR LWA_MESS_ATT.
         SHIFT LV_GD_BUFFER LEFT BY 255 PLACES.
         IF LV_GD_BUFFER IS INITIAL.
           EXIT.
         ENDIF.
       ENDDO.
       CLEAR:  LWA_RECLIST, LT_RECLIST[],
               LT_OBJHEAD, LT_OBJHEAD[],
               LWA_OBJTXT,  LT_OBJTXT[],
               LWA_OBJBIN,  LT_OBJBIN[],
               LWA_OBJPACK, LT_OBJPACK[].
       "   CLEAR LT_OBJBIN.
       REFRESH LT_OBJBIN.
       LT_OBJBIN[] = LT_MESS_ATT[].
       DESCRIBE TABLE  LT_OBJBIN LINES LV_L_ATTACHMENT.
       LWA_OBJTXT = ''.
       APPEND LWA_OBJTXT TO LT_OBJTXT.
       CLEAR LWA_OBJTXT.
       DESCRIBE TABLE LT_OBJTXT LINES LV_L_TESTO.
       LT_DOC_CHNG-OBJ_NAME   = 'STATUS_REPORT'.
       LT_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
       LT_DOC_CHNG-OBJ_DESCR  = 'Generated File'.               "#EC NOTEXT
       LT_DOC_CHNG-SENSITIVTY = 'F'.
       LT_DOC_CHNG-SENSITIVTY = 'O'.
       LT_DOC_CHNG-OBJ_PRIO   = '1'.
       LT_DOC_CHNG-DOC_SIZE   = LV_L_TESTO * 255.
       CLEAR LWA_OBJPACK-TRANSF_BIN.
       LWA_OBJPACK-HEAD_START = 1.
       LWA_OBJPACK-HEAD_NUM   = 0.
       LWA_OBJPACK-BODY_START = 1.
       LWA_OBJPACK-BODY_NUM   = LV_L_TESTO.
       LWA_OBJPACK-DOC_TYPE   = 'RAW'.
       APPEND LWA_OBJPACK TO LT_OBJPACK.
       CLEAR LWA_OBJPACK.
       LWA_OBJPACK-TRANSF_BIN = 'X' .
       LWA_OBJPACK-HEAD_START = 1.
       LWA_OBJPACK-HEAD_NUM   = 1.
       LWA_OBJPACK-BODY_START = 1.
       LWA_OBJPACK-BODY_NUM   = LV_L_ATTACHMENT.
       LWA_OBJPACK-DOC_TYPE   = 'PDF'.
       LWA_OBJPACK-OBJ_NAME   ='SPOOL'.
       LWA_OBJPACK-OBJ_DESCR = 'Test'.     
       LWA_OBJPACK-DOC_SIZE = LV_L_ATTACHMENT * 255.
       APPEND LWA_OBJPACK TO LT_OBJPACK.
       CLEAR LWA_OBJPACK.
       CLEAR LWA_RECLIST.
       LWA_RECLIST-COPY = 'X'.
       LWA_RECLIST-RECEIVER   = P_EMAIL.
       LWA_RECLIST-REC_TYPE   = 'U'.
       LWA_RECLIST-NOTIF_DEL  = 'X'.
       LWA_RECLIST-NOTIF_NDEL = 'X'.
       APPEND LWA_RECLIST TO LT_RECLIST.
       CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
         EXPORTING
           DOCUMENT_DATA              = LT_DOC_CHNG
           PUT_IN_OUTBOX              = ' '
           COMMIT_WORK                = 'X'
         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.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.

  • Convert spool to PDF and send as email attachment

    When i try to convert SAP spool to PDF and send it as email attachment,  size of PDF document becomes large as compared to size of the PDF cocument i download using the same spool.
    I am using following FMs.
    CONVERT_ABAPSPOOLJOB_2_PDF to convert spool to PDF
    and
    SO_NEW_DOCUMENT_ATT_SEND_API1 to send email with attchment.
    some times size of attchment exceeds 2MB and email results in error in SAP connect (SOST).
    Any idea on how to compress the PDF attchment??
    Thanks

    Hi Venkat,
    Can you plesae assist me.
    I have a requirement to convert spool to pdf
    send an email to users
    issue is that attachement is big cant go through
    I have used compress, but when I open the pdf file error that file was not correclty decoded
    please assist, anyone

  • CRM ONLINE 2013: On Approval Of Quotation, Run Report, Generate PDF and Send an Email With PDF as attachment

    Hi,
    I am using CRM ONLINE 2013.
    How to automate below process?
    1. On Approval Of Quotation, Run Report.
    2. Generate PDF.
    3. Send an Email With PDF as attachment.
    As i have gone through many forums for this topic, but creating a plugin code for generating Report PDF is not possible in CRM ONLINE.
    So, What is the alternate way to do this..?
    Thanks.

    This is my entire code mentioned below:-
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
        <script type="text/javascript">
            if (typeof (SDK) == "undefined")
            { SDK = { __namespace: true }; }
            SDK.JScriptRESTDataOperations = {
                _context: function () {
                    if (typeof GetGlobalContext != "undefined")
                    { return GetGlobalContext(); }
                    else {
                        if (typeof Xrm != "undefined") {
                            return Xrm.Page.context;
                        else { return new Error("Context is not available."); }
                _getServerUrl: function () {
                    var serverUrl = this._context().getServerUrl()
                    if (serverUrl.match(/\/$/)) {
                        serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                    return serverUrl;
                _ODataPath: function () {
                    return this._getServerUrl() + "/XRMServices/2011/OrganizationData.svc/";
                _errorHandler: function (req) {
                    return new Error("Error : " +
      req.status + ": " +
      req.statusText + ": " +
      JSON.parse(req.responseText).error.message.value);
                _dateReviver: function (key, value) {
                    var a;
                    if (typeof value === 'string') {
                        a = /Date\(([-+]?\d+)\)/.exec(value);
                        if (a) {
                            return new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
                    return value;
                Create: function (object, type, successCallback, errorCallback) {
                    var req = new XMLHttpRequest();
                    req.open("POST", this._ODataPath() + type + "Set", true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 201) {
                                successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send(JSON.stringify(object));
                Retrieve: function (id, type, successCallback, errorCallback) {
                    var req = new XMLHttpRequest();
                    req.open("GET", this._ODataPath() + type + "Set(guid'" + id + "')", true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 200) {
                                successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send();
                Update: function (id, object, type, successCallback, errorCallback) {
                    var req = new XMLHttpRequest();
                    req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.setRequestHeader("X-HTTP-Method", "MERGE");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 204 || this.status == 1223) {
                                successCallback();
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send(JSON.stringify(object));
                Delete: function (id, type, successCallback, errorCallback) {
                    var req = new XMLHttpRequest();
                    req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.setRequestHeader("X-HTTP-Method", "DELETE");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 204 || this.status == 1223) {
                                successCallback();
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send();
                RetrieveMultiple: function (type, filter, successCallback, errorCallback) {
                    if (filter != null) {
                        filter = "?" + filter;
                    else { filter = ""; }
                    var req = new XMLHttpRequest();
                    req.open("GET", this._ODataPath() + type + "Set" + filter, true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 200) {
                                successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d.results);
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send();
                __namespace: true
        </script>
        <script type="text/javascript">
            //Create Email and link it with Order as Regarding field
            var Xrm;
            var email = new Object();
            var ownerID = "";
            var CustomerId = "";
            if (window.opener) { Xrm = window.opener.Xrm; }
            else if (window.parent) { Xrm = window.parent.Xrm; }
            //Get ownerid who send email of quotation to customer
            function GetOwnerID() {
                var owner = Xrm.Page.getAttribute("ownerid").getValue();
                ownerID = owner[0].id;
                var ownerName = owner[0].name;
                var entityType = owner[0].entityType;
                GetToEmailGUID();
            //Get customerid who receive email of quotation from owner
            function GetToEmailGUID() {
                var Customer = Xrm.Page.getAttribute('customerid').getValue();
                CustomerId = Customer[0].id;
                var CustomerName = Customer[0].name;
                var entityType = Customer[0].entityType;
                //if CustomerId is type of "Account" then get Primary Contact id of that account
                if (entityType == "account") {
                    var contact = Xrm.Page.getAttribute("customerid").getValue();
                    if (contact === null) return;
                    var serverUrl = Xrm.Page.context.getClientUrl();
                    var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'" + contact[0].id + "')?$select=PrimaryContactId";
                    var req = new XMLHttpRequest();
                    req.open("GET", oDataSelect, false);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
                    req.onreadystatechange = function () {
                        if (req.readyState === 4) {
                            if (req.status === 200) {
                                var retrieved = JSON.parse(req.responseText).d;
                                CustomerId = retrieved.PrimaryContactId.Id;
                            else {
                                alert(this.statusText);
                    req.send();
            function CreateEmail() {
                GetOwnerID();
                email.Subject = "Email with Report Attachment";
                //Set The current order as the Regarding object
                email.RegardingObjectId = {
                    Id: Xrm.Page.data.entity.getId(),    //Get the current entity Id , here OrderId
                    LogicalName: Xrm.Page.data.entity.getEntityName()//Get the current entity name, here it will be “salesOrder”
                //Create Email Activity
                SDK.JScriptRESTDataOperations.Create(email, "Email", EmailCallBack, function (error) { alert(error.message); });
            // Email Call Back function
            function EmailCallBack(result) {
                email = result; // Set the email to result to use it later in email attachment for retrieving activity Id
                var activityPartyFrom = new Object();
                // Set the From party of the ActivityParty to relate an entity with Email From field
                activityPartyFrom.PartyId = {
                    Id: CustomerId, //"79EBDD26-FDBE-E311-8986-D89D6765B238",  // id of entity you want to associate this activity with.        
                    LogicalName: "contact"
                // Set the "activity" of the ActivityParty
                activityPartyFrom.ActivityId = {
                    Id: result.ActivityId,
                    LogicalName: "email"
                // Now set the participation type that describes the role of the party on the activity).
                activityPartyFrom.ParticipationTypeMask = { Value: 2 }; // 2 means ToRecipients
                // Create the from ActivityParty for the email
                SDK.JScriptRESTDataOperations.Create(activityPartyFrom, "ActivityParty", ActivityPartyFromCallBack, function (error) { alert(error.message); });
                var activityPartyTo = new Object();
                // Set the From party of the ActivityParty to relate an entity with Email From field
                activityPartyTo.PartyId = {
                    Id: ownerID, //"79EBDD26-FDBE-E311-8986-D89D6765B238",  // id of entity you want to associate this activity with.        
                    LogicalName: "systemuser"
                // Set the "activity" of the ActivityParty  
                activityPartyTo.ActivityId = {
                    Id: result.ActivityId,
                    LogicalName: "email"
                // Now set the participation type that describes the role of the party on the activity).    
                activityPartyTo.ParticipationTypeMask = { Value: 1 }; // 1 means Sender
                // Create the from ActivityParty
                SDK.JScriptRESTDataOperations.Create(activityPartyTo, "ActivityParty", ActivityPartyToCallBack, function (error) { alert(error.message); });
            //ActivityParty From Callback
            function ActivityPartyFromCallBack(result) {
            //ActivityParty To Callback
            function ActivityPartyToCallBack(result) {
                GetReportId('ABM_Infotech_SalesQuote');
            //Create attachment for the created email
            function CreateEmailAttachment() {
                //get reporting session and use the params to convert a report in PDF
                var params = getReportingSession();
                //Email attachment parameters
                var activitymimeattachment = Object();
                activitymimeattachment.ObjectId = Object();
                activitymimeattachment.ObjectId.LogicalName = "email";
                activitymimeattachment.ObjectId.Id = email.ActivityId;
                activitymimeattachment.ObjectTypeCode = "email",
                    activitymimeattachment.Subject = "File Attachment";
                activitymimeattachment.Body = encodePdf(params);
                activitymimeattachment.FileName = "Report1.pdf";
                activitymimeattachment.MimeType = "application/pdf";
                //Attachment call
                SDK.JScriptRESTDataOperations.Create(activitymimeattachment, "ActivityMimeAttachment", ActivityMimeAttachmentCallBack, function (error) { alert(error.message); });
            //ActivityMimeAttachment CallBack function
            function ActivityMimeAttachmentCallBack(result) {
                var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes";
                var width = "800px";
                var height = "600px";
                window.open(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", features);
                // To open window which works in outlook and IE both
                //openStdWin(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", width,
    height, features);
            //This method will get the reportId based on a report name that will be used in            getReportingSession() function
            function GetReportId(reportName) {
                var oDataSetName = "ReportSet";
                var columns = "ReportId";
                var filter = "Name eq '" + reportName + "'";
                retrieveMultiple(oDataSetName, columns, filter, onSuccess);
            function retrieveMultiple(odataSetName, select, filter, successCallback) {
                var serverUrl = Xrm.Page.context.getServerUrl();
                var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
                var odataUri = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "?";
                if (select) {
                    odataUri += "$select=" + select + "&";
                if (filter) {
                    odataUri += "$filter=" + filter;
                $.ajax({
                    type: "GET",
                    contentType: "application/json; charset=utf-8",
                    datatype: "json",
                    url: odataUri,
                    beforeSend: function (XMLHttpRequest) {
                        XMLHttpRequest.setRequestHeader("Accept", "application/json");
                    success: function (data) {
                        if (successCallback) {
                            if (data && data.d && data.d.results) {
                                successCallback(data.d.results);
                            else if (data && data.d) {
                                successCallback(data.d);
                            else {
                                successCallback(data);
                    error: function (XmlHttpRequest, errorThrown) {
                        if (XmlHttpRequest && XmlHttpRequest.responseText) {
                            alert("Error while retrieval ; Error – " + XmlHttpRequest.responseText);
            function onSuccess(data) {
                reportId = data[0].ReportId.replace('{', ").replace('}', ");
                CreateEmailAttachment(); // Create Email Attachment
            //Gets the report contents
            function getReportingSession() {
                var pth = Xrm.Page.context.getServerUrl() + "/CRMReports/rsviewer/reportviewer.aspx";
                var retrieveEntityReq = new XMLHttpRequest();
                var Id = Xrm.Page.data.entity.getId();
                var quotationGUID = Id.replace('{', ""); //set this to selected quotation GUID
                quotationGUID = quotationGUID.replace('}', "");
                var reportName = "ABM_Infotech_SalesQuote"; //set this to the report you are trying to download
                var reportID = "751089AA-74B8-E211-B52F-D8D3855B253B"; //set this to the guid of the report you are trying to download
                var rptPathString = ""; //set this to the CRMF_Filtered parameter
                var strParameterXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='quote'><all-attributes /><filter type='and'><condition
    attribute='quoteid' operator='eq' uitype='quote' value='" + quotationGUID + "' /> </filter></entity></fetch>";
                retrieveEntityReq.open("POST", pth, false);
                retrieveEntityReq.setRequestHeader("Accept", "*/*");
                retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                rptPathString = "id=%7B" + reportID + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName="
    +
                                reportName + "&isScheduledReport=false&p:ABMFilteredQuote=" + strParameterXML;
                //remove the part starting from &p:salesorderid if your report has no parameters
                retrieveEntityReq.send(rptPathString);
                var x = retrieveEntityReq.responseText.indexOf("ReportSession=");
                var ret = new Array();
                ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&", x) - x - 14); //the session id
                x = retrieveEntityReq.responseText.indexOf("ControlID=");
                ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&", x) - x - 10); //the control id
                return ret;
            var bdy = new Array();
            var bdyLen = 0;
            function concat2Bdy(x) {
                bdy[bdyLen] = x;
                bdyLen++;
            function encodePdf(params) {
                bdy = new Array();
                bdyLen = 0;
                var retrieveEntityReq = new XMLHttpRequest();
                var pth = Xrm.Page.context.getServerUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + params[0] +
                "&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + params[1] +
                "&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF";
                retrieveEntityReq.open("GET", pth, false);
                retrieveEntityReq.setRequestHeader("Accept", "*/*");
                retrieveEntityReq.send();
                BinaryToArray(retrieveEntityReq.responseBody);
                return encode64(bdy);
            var StringMaker = function () {
                this.parts = [];
                this.length = 0;
                this.append = function (s) {
                    this.parts.push(s);
                    this.length += s.length;
                this.prepend = function (s) {
                    this.parts.unshift(s);
                    this.length += s.length;
                this.toString = function () {
                    return this.parts.join('');
            var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
            function encode64(input) {
                var output = new StringMaker();
                var chr1, chr2, chr3;
                var enc1, enc2, enc3, enc4;
                var i = 0;
                while (i < input.length) {
                    chr1 = input[i++];
                    chr2 = input[i++];
                    chr3 = input[i++];
                    enc1 = chr1 >> 2;
                    enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
                    enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
                    enc4 = chr3 & 63;
                    if (isNaN(chr2)) {
                        enc3 = enc4 = 64;
                    } else if (isNaN(chr3)) {
                        enc4 = 64;
                    output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4));
                return output.toString();
        </script>
        <script type="text/vbscript">
        Function BinaryToArray(Binary)
               Dim i
               ReDim byteArray(LenB(Binary))
               For i = 1 To LenB(Binary)
                     byteArray(i-1) = AscB(MidB(Binary, i, 1))
                     concat2Bdy(AscB(MidB(Binary, i, 1)))
             Next
              BinaryToArray = byteArray
       End Function     
        </script>
    </head>
    <body>
        <input type="button" onclick="CreateEmail();" value="Attach Report" />
    </body>
    </html>

  • Sending an email of the layout in PDF attachement

    Hello All,
    I have written a program to send the layout in PDF format to send in a mail to the customer.
    The email is going fne with the PDF attachement in the development box, but it is not working in Quality box.
    In the Quality box the email is going but the attachement is not opening.
    I have used CONVERT_OTF function module for converting OTF format to PDF format. As per my analysis it is returning the PDF format properly in Developement box but not the same in Quality. In Quality the the data returning in PDF format is not in proper manner. It is giving some junk data with symbols like traingle, rectange..etc..
    I am using FM SO_OBJECT_SEND for sending an email.
    Can you please suggest me what may be problem?
    Valuable answers will be rewarded.
    Thanks & Regards,
    Satish.

    Hi,
    you need to save the File in PDF format not in the text format.
    check whether the file is saved in pdf format or not.
    Regards,
    Raj.

  • How to send an Email Message along with a PO PDF Attachment in Word.

    I want to send an Email to a customer. The subject of the email is the PDF attachment of the Purchase order.
    Then in the Body of the email, we need to put a small Mesasge in the Body of the Email: Example
    Hello,
    Please see attached Purchase Order.
    thank you...
    Does anyone have a suggestion on how to do this? Best approach?
    thanks
    Walter Poe

    Hi Walter,
    In NACE transaction, select Application EF , then select your P.O Message ( standard is NEU ) .
    Then in "processing routing" parts check that there is an entry for medium 5 ( external send ) , if not please set it with corresponding print program, from routine and forms to use .
    Then in "Mail Title and Text" parts  you can define your mail title with variable and your mail body . Please find below a sample for this. To define the mail body just click on the icon for text ( it's like sapscript text ).
    Mail Title : "Your P.O &EKKO-EBELN"
    Mail Body : "Please find enclosed our P.O &EKKO-EBELN....."
    That's all for NACE parts.
    After this you have to define thru condition that the medium will be used for each P.O. For this check with functionnal consultant if everything is ok and the same that for medium 1.
    Then when you create a P.O, SAP will generate a mail with supplier e-mail adress define in his masterdata . The forms will be converted according to your customizing in transaction SCOT ( node SMTP , Support address type parts) .
    Of course you also have to define a job for sending the mail .
    Hope this help you
    Regards
    Bertrand

  • How to send PDF attachment through Email For Purchase Order

    Hi,
         Can you please tell me how to send the Purchase Order with PDF attachment. Thank you.
    Thanks & Regards,
    Rani.

    Find the below example
    *& Report  ZSPOOLTOPDF                                                 *
    *& Converts spool request into PDF document and emails it to           *
    *& recipicant.                                                         *
    *& Execution                                                           *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on      *
    *& screen                                                              *
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Write statement to represent report output. Spool request is created
    if write statement is executed in background. This could also be an
    ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    Alternative way could be to submit another program and store spool
    id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
           to sap-spool
           spool parameters   %_print
           archive parameters %_print
           without spool dynpro
           and return.
    Get spool id from program called above
    IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
          FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
          FORM get_job_details                                          *
    FORM get_job_details.
    Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
          FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
          FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    perform send_email using p_email2.
    ENDFORM.
          FORM send_email                                               *
    -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
          FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    Reward if helpful.
    Thanks,
    Kishore S N

  • Send PDF form to email address user enters in textfield on form.

    I would like to be able to allow the person using the form to choose what email address the PDF form is emailed to. I read this post which sounds like what I want but I keep getting a Submit Cancelled error. The email does get generated and the form is attached as a PDF so that part works okay.
    http://forums.adobe.com/message/4167414#4167414
    This is the code I am using as I only need the To: address populated.
    form1.Page1.Button1::preSubmit:form - (JavaScript, client)
    var strToAddress
    //Capture the values from the form fields.
    strToAddress = txtToAddress.rawValue;
    event.target.submitForm({cURL:"mailto:"+ strToAddress,cSubmitAs:"PDF",cCharset:"utf-8"});

    Hi,
    There is an example here: http://assure.ly/eUR4wJ.
    // Declare the variable
    var vEmail;
    // Check that the email field is not null
    if (txtToAddress.rawValue !== null) {
         vEmail = txtToAddress.rawValue;
    // Send email
    event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=&body=",cSubmitAs:"PDF",cCharset:"utf-8"});
    Niall

  • Reg: Converting Standard Payslip (PC00_M99_CEDT) to PDF and send via email

    Dear Experts,
    Please provide me a solution to convert the standard Pay slip (PC00_M99_CEDT) Remuneration statement to PDF and send it via email to individual employee by fetching the email ids through the info types.
    I checked the forum, few answers our complete but they have not given the solution.
    Thanks in advance
    Abdur
    Moderator message: moved to requirements forum (points-free!)
    Edited by: Thomas Zloch on Feb 7, 2011 11:53 AM
    Moderator message: moved back to ABAP General.
    Edited by: Thomas Zloch on Feb 9, 2011 1:03 PM

    Dear Experts,
    As suggested, I have written the below code.
    REPORT  ztest_period.
    DATA : td_listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.
    DATA: txtlines(1024) TYPE c OCCURS 0 WITH HEADER LINE.
    DATA: list_tab TYPE TABLE OF abaplist,
          lt_objbin TYPE TABLE OF solisti1 WITH HEADER LINE.
    SUBMIT rpcedtx0 VIA SELECTION-SCREEN EXPORTING LIST TO MEMORY AND RETURN.
    CLEAR td_listobject. REFRESH td_listobject.
    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = td_listobject
      EXCEPTIONS
        not_found  = 1
        OTHERS     = 2.
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    CHECK sy-subrc = 0.
    CALL FUNCTION 'TABLE_COMPRESS'
    TABLES
    in = td_listobject
    out = lt_objbin
    EXCEPTIONS
    compress_error = 1
    OTHERS = 2.
    &code&
    I'm getting the raw data from FM 'LIST_FROM_MEMORY' Please tell me how should i convert it to normal data.
    Once i get the data, I need to send an email for individual personnel number for the respective month.
    Please advice me the next step.
    Thanks and Regards,
    Abdur Rafique
    Edited by: abdur rafique on Feb 21, 2011 11:39 AM

  • How Can I Disallow Sending a PDF Document via Email?

    http://www.tek-tips.com/viewthread.cfm?qid=1528701&page=1
    nha khoa.com/showthread.php?t=145
    I'm using Adobe Acrobat 8 Standard.
    I've gotten the test document setup in such a way that at least the typical person could not print it, send it as an email attachment, nor save the file within Adobe Reader 8.
    However, if that same person were to open the file with Foxit PDF reader, they could email it as an attachment (though they can't do the others).
    What I want to know is if there is a way to specifically disallow a pdf file from being sent as an attachment from within the pdf application? For Adobe, I just had to check the box next to "hide menu bar" and "hide tool bars", but leave "hide window controls" unchecked.
    But of course, Foxit reader, and I'd imagine others, don't recognize the code for the display defaults. So for those, I'd need something else. I did not see an option under security for disabling email. Is there any way to do so?
    The PDF files will be shared via a SharePoint site. So if there is some other better way of locking them down via SharePoint, that'd be fine as well.
    I'll post more detail if need be. Thanks for any suggestions.
    "If to err is human, then I must be some kind of human!" -Me

    There's no way to prevent someone attaching a PDF to an email (or any other file-level operation on it) - to view a PDF it MUST be downloaded to the client's computer, and once there it's a regular file just like any other. There is no "streaming" concept within PDF.
    You can secure the PDF so only certain people can open it (for example using certificate policies or even DRM) but they can still move the file about - it's only at the stage of opening it where the security control starts.
    And you're correct - non-DRM 'permissions' security on a PDF is largely just smoke and mirrors for anyone who can open the file, as removing your print/edit/display preferences is a 10-second job. The only real case of a PDF being "uncrackable" is if the document has a very long OPEN password and the user doesn't know what it is. If they can get as far as seeing the pages on their screen, they can do pretty much anything with it.

  • How do I make a button onj the form which will submit and send the pdf as an email?

    how do I make a button on the form which will submit and send the pdf as an email?

    You can set up a button with a "Submit a form" action and use a mailto type URL to specify the email address you want the forms sent do. If you want to send the entire PDF, select that option and not FDF or anything else. The mailto URL should not include any spaces and the "mailto" part should be lowercase, like:
    mailto:[email protected]
    This will attempt to initiate an email using the users default email client. If the user does not have one set up or there is some other problem, the email might not get initiated. If it needs to work with Reader versions prior to 11, then the form needs to be Reader-enabled, which you do in Acrobat 11 by selecting: File > Save As Other > Reader Extended PDF > Enable More Tools

  • Sap script convert to pdf and then send to email

    Hi,
    good day sap guys
    ive dev the sap scipt for customer statemnet one which is used the t.code is f.27.
    i need to convert the sap script to pdf and then send to email.
    plz let me know..
    how to do it.
    regards
    chandu

    Hi,
       I script program use the following (go to the "call function 'CLOSE_FORM'")
    data: binfilesize type i.
      data: pdftab type table of tline with header line.
      data: i_itcpp like itcpp.
      data: g_t_otfdata type standard table of itcoo with header line.
      call function 'CLOSE_FORM'
       IMPORTING
         RESULT  = i_itcpp
          tables
            otfdata = g_t_otfdata[]
          exceptions
            others  = 1.
      if sy-subrc ne 0.
        retcode = sy-subrc.
        perform protocol_update.
      endif.
      call function 'CONVERT_OTF'
    exporting
    format = 'PDF'
    importing
    bin_filesize = binfilesize
    BIN_FILE =
    tables
    otf = g_t_otfdata[]
    lines = pdftab[].
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    concatenate file_path  '.pdf' into filename.
    call function 'GUI_DOWNLOAD'
      exporting
      bin_filesize = binfilesize
      filename = filename
      filetype = 'BIN'
    APPEND = ' '
    WRITE_FIELD_SEPARATOR = ' '
    HEADER = '00'
    TRUNC_TRAILING_BLANKS = ' '
    WRITE_LF = 'X'
    COL_SELECT = ' '
    COL_SELECT_MASK = ' '
    DAT_MODE = ' '
    CONFIRM_OVERWRITE = ' '
    NO_AUTH_CHECK = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    WRITE_BOM = ' '
    TRUNC_TRAILING_BLANKS_EOL = 'X'
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    IMPORTING
    FILELENGTH =
      tables
      data_tab = pdftab[]
    FIELDNAMES =
      exceptions
      file_write_error = 1
      no_batch = 2
      gui_refuse_filetransfer = 3
      invalid_type = 4
      no_authority = 5
      unknown_error = 6
      header_not_allowed = 7
      separator_not_allowed = 8
      filesize_not_allowed = 9
      header_too_long = 10
      dp_error_create = 11
      dp_error_send = 12
      dp_error_write = 13
      unknown_dp_error = 14
      access_denied = 15
      dp_out_of_memory = 16
      disk_full = 17
      dp_timeout = 18
      file_not_found = 19
      dataprovider_exception = 20
      control_flush_error = 21
      others = 22
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.

  • To send output as a PDF attachment via email

    Hi experts
    I have the (smartform) output data in OTF format..and displaying it in PDF form with FM 'HR_EFI_SHOW_PDF_FORM' .
    Now the requirement is <b>to send this output as a PDF attachment via email</b>.
    Please help me with sample code to perform this.
    Regards,
    Matt.

    Hi,
    Check this links,
    /people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
    Also for email:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8cd6adbb-0301-0010-39ba-938c601d5db9
    Refer the following link for more details:
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    Thanks,
    Reward If Helpful.

Maybe you are looking for

  • 2nd gen Shuffle gets unmounted by iTunes 7.5.0.20 (doesn't sync) workaround

    My cousin recently gave me his Shuffle because it was not working for him on his XP Pro machine. He bought a new Nano. I have used the separate "iPod reset utility" to restore my Shuffle. The first time that iTunes sees it, when you assign a name, if

  • I lost Itunes on mac os x 10.5.8. What can I do ?

    I lost Itunes on mac os x 10.5.8. What can I do ?

  • Conversion problems with Memo field in Access database

    I have the latest version of Migration Workbench and the Access 2000 plug-in. I am using an ODBC driver, and the SQL conversion requirements for converting to a native driver seem too time and labor intensive to be feasable. My problem is that I have

  • HR-AUTHORIZATION PB10

    Hi all, This is regarding authorization issue I am raising this question. We are in the implementation of SAP-HR module to our client.Please find my client requirement as follows. In transaction pb10(initial entry of basic data),I need to restrict th

  • Upgrade path from CC&B 1.5.x to 2.4

    Hi, Has anyone done an upgrade from CC&B 1.5.15 to 2.3.1 or 2.4? The release notes in 2.4 say that the one-step upgrade is only available from 2.1 and above, so I would like to understand what steps are necessary for upgrading 1.5.15. Should I even a