Urgent: Sending an Email with Excel sheet attachment

Hi All,
I am preparing a report and has to send mail with excel sheet attachement. In report i am getting everything fine. But in the mail i am not getting the data, data is passing to the FM succesfully. But in the mail, excel is not having full data.
the below mentioned is my code.
i_texts-line = c_stern.
  i_texts-line+254(1) = c_newline.
  APPEND i_texts.
  LOOP AT i_texc.
    i_att_line-line = i_texc.
    APPEND i_att_line.
  ENDLOOP.
  DATA: wa_doc_chng LIKE sodocchgi1.
  DATA: w_tab_lines LIKE sy-tabix.
  STATICS: c_body_start TYPE i VALUE '1'.
  CONSTANTS: lc_filename(10) TYPE c VALUE 'Attachment',
             lc_atthead(30)  TYPE c VALUE 'Manually released invoices'.
  DATA: i_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
  DATA: w_doc_name(30) TYPE c.
  DATA: l_text1(15),
        l_text2(12),
        l_text3(15),
        l_text4(15),
        l_text5(14),
        l_text6(17),
        l_text7(10),
        l_text8(20),
        l_text9(19),
        l_text10(19),
        l_text11(19),
        l_text12(16),
        l_text13(20),
        l_text14(19),
        l_text15(19),
        l_text16(30).
  DATA: DATE(10),
        DT(2),
        MON(3),
        YR(4),
        lc_final(50).
  CLEAR: i_texts, i_reci,i_att_line.                "i_bname,
  REFRESH: i_texts, i_reci,i_att_line.              "i_bname,
  WRITE sy-datum TO w_datex.
  WRITE sy-uzeit TO w_timex.
  l_text1 = text-003.
  l_text2 = text-004.
  l_text3 = text-005.
  l_text4 = text-006.
  l_text5 = text-007.
  l_text6 = text-008.
  l_text7 = text-009.
  l_text8 = text-010.
  l_text9 = text-011.
  l_text10 = text-012.
  l_text11 = text-013.
  l_text12 = text-014.
  l_text13 = text-015.
  l_text14 = text-016.
  l_text15 = text-017.
  l_text16 = text-026.
  CONCATENATE
  l_text1
  l_text2
  l_text3
  l_text4
  l_text5
  l_text6
  l_text7
  l_text8
  l_text9
  l_text10
  l_text11
  l_text12
  l_text13
  l_text14
  l_text15
  l_text16
  INTO i_texts SEPARATED BY
  c_horz_tab.
  i_texts-line+254(1) = c_newline.
  APPEND i_texts.
  CLEAR  i_texts.
  LOOP AT i_texc.
    i_att_line-line = i_texc.
    APPEND i_att_line.
  ENDLOOP.
  LOOP AT so_rec.
    i_reci-receiver = so_rec-low.
    i_reci-express = 'X'.
    i_reci-rec_type = 'U'.
    APPEND i_reci.
  ENDLOOP.
  DESCRIBE TABLE i_texts LINES w_tab_lines.
  READ TABLE i_texts INDEX w_tab_lines.
  wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
  wa_obj_name   = 'ZFI_XX_REL_BLOCKED_INVOICE_01'.
  DT  = SY-DATUM+6(2).
  MON = SY-DATUM+4(2).
  YR  = SY-DATUM+0(4).
  CONCATENATE DT MON YR INTO DATE SEPARATED BY '-'.
  CONCATENATE lc_atthead date into lc_final separated by ' '.
  MOVE lc_final
               TO wa_obj_descr .
  wa_doc_chng-obj_name  = wa_obj_name.
  wa_doc_chng-obj_descr = wa_obj_descr.
  CLEAR i_objpack-transf_bin.
  i_objpack-head_start = 1.
  i_objpack-head_num = 0.
  i_objpack-body_start = 0.
  i_objpack-body_num = w_tab_lines.
  i_objpack-doc_type = 'RAW'.
  APPEND i_objpack.
  APPEND LINES OF i_att_line TO i_texts.
  LOOP AT i_arseg INTO wa_arseg.
    i_xmplt_d-belnr = wa_arseg-belnr.
    i_xmplt_d-budat = wa_arseg-budat.
    i_xmplt_d-bukrs = wa_arseg-bukrs.
    i_xmplt_d-lifnr = wa_arseg-lifnr.
    i_xmplt_d-name1_lifnr = wa_arseg-name1_lifnr.
    i_xmplt_d-wrbtr = wa_arseg-wrbtr.
    i_xmplt_d-waers = wa_arseg-waers.
    i_xmplt_d-ebeln = wa_arseg-ebeln.
    i_xmplt_d-ebelp =  wa_arseg-ebelp.
    i_xmplt_d-reason = wa_arseg-reason.
    i_xmplt_d-dmeng = wa_arseg-dmeng.
    i_xmplt_d-dwert = wa_arseg-dwert.
    i_xmplt_d-bname = wa_arseg-bname.
    i_xmplt_d-name_text = wa_arseg-name_text.
    i_xmplt_d-udate = wa_arseg-udate.
    i_xmplt_d-comment =  wa_arseg-comment.
    APPEND i_xmplt_d.
  ENDLOOP.
  LOOP AT i_xmplt_d.
    CONCATENATE i_xmplt_d-belnr
                i_xmplt_d-budat
                i_xmplt_d-bukrs
                i_xmplt_d-lifnr
                i_xmplt_d-name1_lifnr
                i_xmplt_d-wrbtr
                i_xmplt_d-waers
                i_xmplt_d-ebeln
                i_xmplt_d-ebelp
                i_xmplt_d-reason
                i_xmplt_d-dmeng
                i_xmplt_d-dwert
                i_xmplt_d-bname
                i_xmplt_d-name_text
                i_xmplt_d-udate
                i_xmplt_d-comment
                INTO i_texts SEPARATED
                BY c_horz_tab.
    i_texts-line+254(1) = c_newline.
    APPEND i_texts.
    CLEAR i_texts.
  ENDLOOP.
  DESCRIBE TABLE i_texts LINES w_tab_lines.
  READ TABLE i_texts INDEX w_tab_lines.
  wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
  DESCRIBE TABLE i_texts LINES w_tab_lines.
  i_objpack-transf_bin = ' '.
  i_objpack-head_start = 0.
  i_objpack-head_num = 0.
  i_objpack-body_start = 1.
  i_objpack-body_num = w_tab_lines.
  i_objpack-doc_type = 'XLS'.
  i_objpack-obj_name = 'Attachment'.
i_objpack-obj_descr = w_doc_name.
  i_objpack-obj_descr = lc_filename.
  i_objpack-doc_size = w_tab_lines * 255.
  APPEND i_objpack.
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = wa_doc_chng
    TABLES
      packing_list               = i_objpack
      contents_txt               = i_texts
      receivers                  = i_reci
    EXCEPTIONS
      too_many_receivers         = 1
      document_not_sent          = 2
      operation_no_authorization = 4
      OTHERS                     = 99.
  IF sy-subrc = 0.
    COMMIT WORK.
  ELSE.
    WRITE: / 'Error in send E-Mail' .
  ENDIF.
please revert me asap. It is very urgent to me. thanks in advance.
Bye

hI
Have you build your Excel Data table to get attachement in Mail? If no then please find the Eg. code for your reference to send Excel attachment..
* End of Selection Event : Displaying the selected data                *
END-OF-SELECTION.
    PERFORM EMAIL_EXCEL_ATTACHMENT.
******///form
FORM EMAIL_EXCEL_ATTACHMENT .
* Populate table with detaisl to be entered into .xls file
  PERFORM BUILD_XLS_DATA_TABLE.
* Populate message body text
  PERFORM POPULATE_EMAIL_MESSAGE_BODY.
* Send file by email as .xls speadsheet
  PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
                               TABLES IT_MESSAGE
                                      IT_ATTACH
                                USING S_EMAIL
                                      TEXT-042
                                      C_XLS
                                      'filename'
                             CHANGING GD_ERROR
                                      GD_RECIEVER.
*   Instructs mail send program for SAPCONNECT to send email(rsconn01)
  PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
ENDFORM.                    " EMAIL_EXCEL_ATTACHMENT
********///form BUILD_XLS_DATA_TABLE
FORM BUILD_XLS_DATA_TABLE .
  DATA :    LV_NETWR(20)     TYPE C,
            LV_BOL_DATE(20)  TYPE C,
            LV_KAWRT(20)     TYPE C,
            LV_FKDAT(20)     TYPE C,
            LV_WAERK(20)     TYPE C,
            LV_KURRF(20)     TYPE C,
            LV_SHIPDATE(20)  TYPE C,
            LV_DEPTDATE(20)  TYPE C.
  CONSTANTS:
      CON_TAB  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
      CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.  "#EC *
  DATA STR TYPE STRING.
**********/ this parameter concatenate to get headers
  CONCATENATE STR
  'SLNO'
  'OWNER'
  'SERIAL NO'
  'FROM'
  'DESTINATION'
  'INVOICE VALUE'
  'DESCRIPTION'
  'CUSTOMER NAME'
  'BL NUMBER'
  'BL DATE'
  'VESSEL NAME/AIRLINE DETAILS'
  'MODE OF TRANSIT'
  'SHIPPING MARKS'
  'DUTY SUM INSURED'
  'FLAG'
  'OPEN COVERNO'
  'INVOICE DATE'
  'INVOICE NO'
  'LC WORDING'
  'QUANTITY'
  'PACKAGING DETAILS'
  'BASIS OF VALUATION'
  'EXCLUDE WAR SRCC'
  'CURRENCY'
  'EXCHANGE RATE'
  'ADDRESS'
  'VESSEL BUILT YEAR'
  'VESSEL FLAG'
  'VOYAGE NO'
  'SHIPMENT DATE'
  'DEPARTURE DATE'
  'SURVEYOR COUNTRY'
  'SURVEYOR CITY'
  'SURVEYOR AGENT'
  'SURVEYOR ADDRESS'
  'EXPORT CONSIGNMENT'
  'CONTAINER DETAILS'
  CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
  LOOP AT IT_FINAL.
*******/ this is to pass body / row data
    WRITE : IT_FINAL-NETWR    TO LV_NETWR,              "#EC UOM_IN_MES
            IT_FINAL-BOL_DATE TO LV_BOL_DATE,
            IT_FINAL-KAWRT    TO LV_KAWRT,              "#EC UOM_IN_MES
            IT_FINAL-FKDAT    TO LV_FKDAT,
            IT_FINAL-WAERK    TO LV_WAERK,
            IT_FINAL-KURRF    TO LV_KURRF,
            IT_FINAL-SHIPDATE TO LV_SHIPDATE,
            IT_FINAL-DEPTDATE TO LV_DEPTDATE.
    CONCATENATE
           STR
           IT_FINAL-SLNO
           IT_FINAL-OWNER
           IT_FINAL-SRNO
           IT_FINAL-PORT_LOAD
           IT_FINAL-PORT_DSCHR
           LV_NETWR
           IT_FINAL-DESCRIP
           IT_FINAL-CUSTNAME
           IT_FINAL-BOL_NUM
           LV_BOL_DATE
           IT_FINAL-VESSELNAME
           IT_FINAL-SHP_TYPE
           IT_FINAL-SHP_MARK
           LV_KAWRT
           IT_FINAL-FLAG
           IT_FINAL-OPEN_CONO
           LV_FKDAT
           IT_FINAL-VBELN
           IT_FINAL-LC_WORD
           IT_FINAL-QUANT
           IT_FINAL-PACKDETL
           IT_FINAL-INCO1
           IT_FINAL-EXCWSR
           LV_WAERK
           LV_KURRF
           IT_FINAL-ADDPAY
           IT_FINAL-VESSBYR
           IT_FINAL-VESSFLG
           IT_FINAL-VOY_FLY_NO
           LV_SHIPDATE
           LV_DEPTDATE
           IT_FINAL-SURCOUNT
           IT_FINAL-INCO2
           IT_FINAL-EXPORT_CON
           IT_FINAL-SURAGT
           IT_FINAL-SURADD
           IT_FINAL-CONTRNO
   CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
  ENDLOOP.
  CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
    EXPORTING
      TEXT      = STR
    TABLES
      FTEXT_TAB = IT_ATTACH.
ENDFORM.                    " BUILD_XLS_DATA_TABLE
******// form POPULATE_EMAIL_MESSAGE_BODY
FORM POPULATE_EMAIL_MESSAGE_BODY .
  REFRESH IT_MESSAGE.
  IT_MESSAGE = TEXT-043.  " Please find attached Insurance Certificate details
  APPEND IT_MESSAGE.
ENDFORM.                    " POPULATE_EMAIL_MESSAGE_BODY
*******'/ form SEND_FILE_AS_EMAIL_ATTACHMENT
*&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
*       text
*      -->PIT_MESSAGE           text
*      -->PIT_ATTACH            text
*      -->P_EMAIL               text
*      -->P_MTITLE              text
*      -->P_FORMAT              text
*      -->P_FILENAME            text
*      -->P_ATTDESCRIPTION      text
*      -->P_SENDER_ADDRESS      text
*      -->P_SENDER_ADDRES_TYPE  text
*      -->P_ERROR               text
*      -->P_RECIEVER            text
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
                                          PIT_ATTACH
                                    USING P_EMAIL
                                          P_MTITLE
                                          P_FORMAT
                                          P_FILENAME
                                          P_ATTDESCRIPTION
                                          P_SENDER_ADDRESS
                                          P_SENDER_ADDRES_TYPE
                                 CHANGING P_ERROR
                                          P_RECIEVER.       "#EC *
  DATA: LD_ERROR    TYPE SY-SUBRC,                          "#EC *
*        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.                         "#EC *
*  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.
  DESCRIBE TABLE IT_ATTACH LINES W_CNT.
  READ TABLE IT_ATTACH INDEX W_CNT.
  W_DOC_DATA-DOC_SIZE =
     W_CNT * 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[] = PIT_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.
  LOOP AT S_EMAIL.
    T_RECEIVERS-RECEIVER = S_EMAIL-LOW.
    T_RECEIVERS-REC_TYPE = 'U'.
    T_RECEIVERS-COM_TYPE = 'INT'.
    T_RECEIVERS-NOTIF_DEL = 'X'.
    T_RECEIVERS-NOTIF_NDEL = 'X'.
    APPEND T_RECEIVERS.
  ENDLOOP.
  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.                    " SEND_FILE_AS_EMAIL_ATTACHMENT
*******/form
*&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
*       text
*  -->  p1        text
*  <--  p2        text
FORM INITIATE_MAIL_EXECUTE_PROGRAM .
  WAIT UP TO 2 SECONDS.
  SUBMIT RSCONN01 WITH MODE = 'INT'
                WITH OUTPUT = 'X'
                AND RETURN.
ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
*********end of code to trigger mail in excel format....
If any other help please let me know......
I am sure this example code will help you to resolve your problem...
please analyse above code for your requirement...
In my scenario the message you said is not displaying.....
Reward Points

Similar Messages

  • Why can I not attach a document to an email? Every time I want to send an email with a document attached to it, an error notice pops out. It tell me that the file is being used even when  it is not. How can I fix this issue?

    Why can I not attach a document to an email? Every time I want to send an email with a document attached to it, an error notice pops out. It tells me that the file is being used even when  iall other programs are closed. How can I fix this issue?

    Thanks Jeff, I was not aware that a template could be multi-page.  (All the existing templates were 1 page)
    But it worked, saving me some steps.  When I was finished I renamed the document, and locked it.
    Then tried to save it but  could not because it was locked.  I closed it, went to my Spread Sheet Folder ,
    to find it, it was not there.  The Finder could not find it either.
    So I start over again.
    I opened up Numbers and it showed my personal Numbers template folder, it contained both my new 
    original 4 page template and the vanished saved document!
    I tried to delete the template containing these document data and could not - I had to go to the Library/Application Support/Numbers to physically remove it from this folder. Then I started over again.  I Finally found out how to make it work: I can now "save as", and then lock, and it will go to place where I want it to be saved and locked.
    The secret is: Click on the document title in the menu bar, and it opens up  "Save as...", which works the same as in OS 10.4.11, and you can pick the place you want for saving.  Once done that, you can then lock the document in the same pull down menu, and then close it.
    I also found later that I can delete a template from its folder, by letting Numbers open the templates,
    clicking on the one I want to remove, then go to the "Numbers Menu/File/Move to...", select "Desktop"
    and from there the selected template can then be thrown into the Trash from there.
    It appears now that the real fault of the Numbers software is that the "Save as" command is not available in the "Edit" or "File" pull-down menus, but hidden behind the title of the document.

  • 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 with Excel Attachment from Local directory

    Hi,
    I have a requirement : I want to send an email with an attachment which is exist on local  directory and currently I am using
    cl_bcs classes
    Thanks,
    Moderator message: Welcome to SCN!
    Moderator message: please do more research before asking, show what you have done yourself when asking.
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers]
    Edited by: Thomas Zloch on Aug 4, 2011 5:15 PM

    Hi,
    I have a requirement : I want to send an email with an attachment which is exist on local  directory and currently I am using
    cl_bcs classes
    Thanks,
    Moderator message: Welcome to SCN!
    Moderator message: please do more research before asking, show what you have done yourself when asking.
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers]
    Edited by: Thomas Zloch on Aug 4, 2011 5:15 PM

  • Please help, I'm unable to send an email with a pdf attachment

    We have Windows 8 Pro on the pc, I have been trying to send a pdf document that my husband needs to his work and no matter how I try to send it (either from reader or directly from my email with the attachment it just will not send.  Can anyone please help?

    No worries.  But it is strange that you cannot even send email with a PDF attachment from Microsoft Mail.  At this point, no PDF viewers (e.g. Microsoft Reader, Adobe Reader Touch) are involved because you are not viewing PDF files.
    Instead of saying "It won't send", you need to describe exactly what you see on the screen for every step. Where does the problem start? 
    Step 1: Attaching a PDF file to new email in Microsoft Mail
    Are you able to find the PDF file and attach it to new email?
    Step 2: Sending email with a PDF attachment
    What happens when you click the Send button?  Does it hang forever?  Does it show an error message? Could you confirm that you can send email with other type of attachments (e.g. text file, Word file) from Microsoft Mail from the same PC?
    You can provide the details to Microsoft for troubleshooting.
    Alternatively, you can try to send email with the PDF attachment from other accounts like Gmail (Google Mail) or Yahoo Mail via the web browser (Internet Explorer) interface.
    Sometimes, rebooting your system solves "mysterious" problems, too.
    Good luck!

  • Sending an email with an image attachment

    Hello
    Basicly I want to send an email with an image as attachment.
    The image is taken by the user in the same app.
    It is an android app
    This is the code i've got so far.
    http://pastebin.com/wVDZsgHx
    can anyone help me please
    I've found out that you have to do it server side with php, but I have no idea how to begin with it.

    Hmmm, Permissions are messed up somewhere!?
    Can you open to pic say in Preview, select All, Copy, 7 Paste into Mail?

  • Need to send email with excel sheet as attachment: URGENT

    Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
    For kind information...there is only one selection field for entering the mail id.
    Thanks in advance
    Nanda

    Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
    For kind information...there is only one selection field for entering the mail id.
    Thanks in advance
    Nanda

  • How to send huge no. of excel sheet attachment to a mail ID

    HI ,
            I have mail functionality program which send mail to a mail id with multiple excel sheet attchment. I have done all these things.  When it sends small number of excel attchment  then it's ok. But when  it sends huge number of excel attchment (ex.- 1000 excel attchment) then it showing error message to the mail  id -
       'This message is larger than the size limit for messages. Please make it smaller and try sending it again.'
    I have used cl_bcs, cl_document_bcs these class. I have seen all related post in sdn but unable to get my requirement.
    i need your suggestion.

    Hi,
    Try this code::
    FORM MAIL_SEND .
      *Mail Body
      MOVE text-004 TO wa_text.  "Space
      APPEND wa_text TO wt_text.
      CLEAR wa_text.
      MOVE TEXT-003 TO wa_text.
      APPEND wa_text TO wt_text.
      CLEAR wa_text.
      MOVE text-005 TO wa_text.
      APPEND wa_text TO wt_text.
      CLEAR wa_text.
      MOVE TEXT-003 TO wa_text.
      APPEND wa_text TO wt_text.
      CLEAR wa_text.
      MOVE text-011 TO wa_text.
      APPEND wa_text TO wt_text.
      CLEAR wa_text.
      tl_contents[] = wt_text.
      TRY.
        TRY.
    **-- Create persistent send request
          l_send_request = cl_bcs=>create_persistent( ).
          CATCH CX_SEND_REQ_BCS.
       ENDTRY.
    *-- Get the length of the Document
          DESCRIBE TABLE tl_contents LINES l_cnt.
          READ TABLE tl_contents INTO wa_contents INDEX l_cnt.
          l_doc_len = ( l_cnt - 1 ) * 255 + STRLEN( wa_contents ).
    *-- Subject of the mail
          l_sub = 'TEST1'.
          I_SUBJECT = 'BP assignment report for Credit analyst and CrSeg'.
    **-- Create Document
          l_document = cl_document_bcs=>create_document(
                 i_type       = c_htm
                 i_text       = tl_contents
                 i_length     = l_doc_len
                 i_subject    = I_SUBJECT "'BP assignment report for Credit analyst and CrSeg
                 i_language   = sy-langu
                 i_importance = '1' ).
        CATCH CX_DOCUMENT_BCS.
    **-- Subject of the mail
          MOVE l_sub TO l_subj.
      ENDTRY.
      TRY.
    *-- Set the Message Subject
          CALL METHOD l_send_request->set_message_subject
            EXPORTING
              ip_subject = l_subj.
        CATCH CX_SEND_REQ_BCS.
      ENDTRY.
    **-- Add document to send request
      try.
          CALL METHOD l_send_request->set_document( l_document ).
        CATCH CX_SEND_REQ_BCS.
      endtry.
      CALL FUNCTION 'SPLIT_FILENAME'
        EXPORTING
          long_filename  = 'C:\BP_DETAILS.XLS'
        IMPORTING
          pure_filename  = p_name
          pure_extension = p_ext.
      TRANSLATE p_ext TO UPPER CASE.
      elpath = 'C:\BP_DETAILS.XLS'.
    *Upload the file
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = elpath
          filetype                = 'BIN'
        TABLES
          data_tab                = t_ann
        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.
    ENDIF.
      try.
          IF t_ann[] IS NOT INITIAL.
    *-- File name of the Attachment
            l_subject  = p_name.
    *-- Extension of the Attachment
            l_att_type = p_ext.
            TRY.
                w_document = l_document.
    *-- Add Attachment to the Document
                CALL METHOD L_document->add_attachment
                  EXPORTING
                    i_attachment_type    = l_att_type
                    i_attachment_subject = l_subject
                    i_att_content_hex    = t_ann. "t_mailhex.
              CATCH cx_document_bcs.
            ENDTRY.
          ENDIF.
    *-- Do send delivery info for successful mails
          lv_msg = 'E'.
          CALL METHOD l_send_request->set_status_attributes
            EXPORTING
              i_requested_status = lv_msg  "Error status
              i_status_mail      = lv_msg. "Error status
          TRY.
              send_request = l_send_request->send_request.
            CATCH cx_bcs.
          ENDTRY.
    set outbox flag
          TRY.
              CALL METHOD send_request->set_link_to_outbox( 'X' ).
            CATCH cx_bcs.
          ENDTRY.
    request error status
          TRY.
              CALL METHOD send_request->setu_requested_status( req_stat ).
            CATCH cx_bcs INTO l_bcs_exception.
          ENDTRY.
    *-- Set sender
          l_sender = cl_sapuser_bcs=>create( sy-uname ).
          CALL METHOD l_send_request->set_sender
            EXPORTING
              i_sender = l_sender.
          gs_mail-e_mail = 'mail ID1'.
          APPEND gs_mail TO gt_mail.
          CLEAR gs_mail.
          gs_mail-e_mail = 'mail ID2'.
          APPEND gs_mail TO gt_mail.
          CLEAR gs_mail.
          gs_mail-e_mail = 'mail ID3'.
          APPEND gs_mail TO gt_mail.
          CLEAR gs_mail.
          loop at gt_mail into gs_mail.
            try.
                l_recipient = cl_cam_address_bcs=>create_internet_address(
                                                                    gs_mail-e_mail ).
              catch cx_address_bcs.
            endtry.
            CALL METHOD l_send_request->add_recipient
              EXPORTING
                i_recipient = l_recipient
               i_express   = 'X'
                i_copy      = 'X'.
          endloop.
    *-- Send Email
          CALL METHOD l_send_request->send(
              EXPORTING
                i_with_error_screen = 'X'
              RECEIVING
                result              = l_result ).
        CATCH cx_bcs INTO l_bcs_exception.
      ENDTRY.
      COMMIT WORK.
    ENDFORM.
    Thanks

  • Sending an email with an XSTRING attachment

    How can I send an email from ABAP with an Attachment that is stored in an XSTRING?
    Regards,
    Javier

    Hi Raja,
    I got a similar requirement.
    I have an ALV report which shows more than 255 characters. I mean, my internal table row contains more than 500 chars.
    I want send the report as Excel attachment in the similar format.
    I was trying but, the table length to send email is 255 per row.. So I did not get about how to do it.
    Can you suggest about how to do it?
    Thanks,
    Sreekanth

  • FM to send an email with a PDF attachment

    Hello All,
        Please suggest me some FMs to send an email along with PDF attachment.
    Thanks,

    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***********************
          w_objhead   TYPE soli_tab,
          w_ctrlop    TYPE ssfctrlop,
          w_compop    TYPE ssfcompop,
          w_return    TYPE ssfcrescl,
          w_doc_chng  TYPE sodocchgi1,
          w_data      TYPE sodocchgi1,
          w_buffer    TYPE string."To convert from 132 to 255
    data:     v_len_in     TYPE sood-objlen,
         v_len_out    TYPE sood-objlen,
         v_len_outn   TYPE i,
         v_lines_txt  TYPE i,
         v_lines_bin  TYPE i.
    start-of-selection.
      w_ctrlop-getotf    = gv_abaptrue.
      w_ctrlop-no_dialog = gv_abaptrue.
      w_compop-tdnoprev  = gv_abaptrue.
    PERFORM call_smartform.
      PERFORM convert_to_otf_format.
      PERFORM pdf_formatting.
      PERFORM build_mail_format.
      PERFORM send_mail.
    form call_smartform.
    DATA:fm_name  TYPE rs38l_fnam.
      DATA:formname TYPE tdsfname VALUE 'ZSD_CRM_PROFORMA_INVOICE_001'.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname = formname
        IMPORTING
          fm_name  = fm_name.
      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 fm_name
        EXPORTING
          control_parameters = w_ctrlop
          output_options     = w_compop
          user_settings      = ' '
          v_vbeln            = v_vbeln
          v_erdat            = gv_dat
          wa_custaddr        = gw_zcustaddr
          v_stceg            = gw_kna1-stceg
          v_total            = gv_total
          vbak               = vbak
          v_lifnr            = gw_kna1-lifnr
          vbrp               = vbrp
          v_head             = gv_heading
          v_taxtext          = gv_text
          v_tax              = gv_tax
          v_gtotal           = gv_gtot
        IMPORTING
          job_output_info    = w_return
        TABLES
          it_det             = gt_items
        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.
    endform.
    form convert_to_otf_format.
      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.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    endform.
    form pdf_formatting.
    * Convert PDF from 132 to 255.
      LOOP AT i_tline.
    * Replacing space by ~
        TRANSLATE i_tline USING ' ~'.
        CONCATENATE w_buffer i_tline INTO w_buffer.
      ENDLOOP.
    * Replacing ~ by space
      TRANSLATE w_buffer USING '~ '.
      DO.
        i_record = w_buffer.
    * Appending 255 characters as a record
        APPEND i_record.
        SHIFT w_buffer LEFT BY 255 PLACES.
        IF w_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    endform.     
    FORM build_mail_format .
    DATA:lv_dash(1)         TYPE c VALUE '-'.
      DATA:lv_xtn(4)          TYPE c VALUE '.pdf'.
      CONSTANTS:lv_esacpe     TYPE so_escape  VALUE 'U'.
      CONSTANTS:lv_so_obj_tp  TYPE so_obj_tp  VALUE 'PDF'.
      CONSTANTS:lv_so_obj_tp1 TYPE so_obj_tp  VALUE 'RAW'.
      CONSTANTS:lv_so_obj_sns TYPE so_obj_sns VALUE 'F'.
    * Get Email ID's
      SELECT * INTO TABLE gt_address[] FROM adr6
      WHERE addrnumber = gw_kna1-adrnr.
      REFRESH:i_reclist,
              i_objtxt,
              i_objbin,
              i_objpack.
      CLEAR w_objhead.
    * Object with PDF.
      i_objbin[] = i_record[].
      DESCRIBE TABLE i_objbin[] LINES v_lines_bin.
    * Object with main text of the mail.
      i_objtxt = text-002.
      APPEND i_objtxt.
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
    * Document information.
      w_doc_chng-obj_name = text-005.
      w_doc_chng-expiry_dat = sy-datum + 10.
      IF gw_flg = 'T'.
        w_doc_chng-obj_descr = text-003.
      ELSE.
        w_doc_chng-obj_descr = text-004.
      ENDIF.
      CONCATENATE w_doc_chng-obj_descr lv_dash v_vbeln INTO w_doc_chng-obj_descr.
      w_doc_chng-sensitivty = lv_so_obj_sns. "Functional object
      w_doc_chng-doc_size = v_lines_txt * 255.
    * Pack to main body as RAW.
    * Obj. to be transported not in binary form
      CLEAR i_objpack-transf_bin.
    * Start line of object header in transport packet
      i_objpack-head_start = 1.
    * Number of lines of an object header in object packet
      i_objpack-head_num = 0.
    * Start line of object contents in an object packet
      i_objpack-body_start = 1.
    * Number of lines of the object contents in an object packet
      i_objpack-body_num = v_lines_txt.
    * Code for document class
      i_objpack-doc_type = lv_so_obj_tp1.
      APPEND i_objpack.
    * Packing as PDF.
      i_objpack-transf_bin = gv_abaptrue.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = lv_so_obj_tp.
      i_objpack-obj_name = text-005.
      CONCATENATE w_doc_chng-obj_descr lv_xtn INTO i_objpack-obj_descr.
      i_objpack-doc_size = v_lines_bin * 255.
      APPEND i_objpack.
    * Document information.
      CLEAR i_reclist.
    * e-mail receivers.
      LOOP AT gt_address INTO gw_adr6.
        i_reclist-receiver = gw_adr6-smtp_addr.
        i_reclist-express =  gv_abaptrue.
        i_reclist-rec_type = lv_esacpe. "Internet address
        APPEND i_reclist.
      ENDLOOP.
    endform.
    FORM send_mail .
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = w_doc_chng
          put_in_outbox              = ' '
        TABLES
          packing_list               = i_objpack[]
          object_header              = w_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.
      ENDIF.
      COMMIT WORK.
    ENDFORM.  
    hi this is a program for sending smartform as pdf attachment.
    make the necessary modifications in the OTF part and use it
    Edited by: Keshu Thekkillam on Jul 10, 2009 7:17 PM
    Edited by: Keshu Thekkillam on Jul 10, 2009 7:17 PM

  • Problems sending an email with a field attached.

    Hi everyone,
    I’m having problems with sending an e-mail (with a field attached) to an external e-mail address.
    I’m using the followings functions:
    <b>'SO_DOCUMENT_INSERT'
    'SO_OBJECT_UPLOAD'
    'SO_ATTACHMENT_INSERT'
    'SO_OBJECT_SEND'</b>
    Everything goes well (the functions are executed well), but the message stacks and it isn’t be sent.
    I can see it with the transaction SBWP, it is in the folder Exit/Documents with status: “Waiting communication service” .
    Then I can send it from there clicking at the button send. And then it is sent.
    Have anyone any clue about what I’ve missed to do.
    I really appreciate your help; I need to solve this problem as soon as possible.
    Kind regards.

    Hai
    report zemail no standard page heading line-size 220.
    data: message_content like soli occurs 10 with header line,
            receiver_list like soos1 occurs 5 with header line,
            w_object_hd_change like sood1.
    start-of-selection.
    Receivers
    receiver_list-recextnam = '[email protected]'.
    receiver_list-recesc = 'E'.
    receiver_list-sndart = 'INT'
    receiver_list-sndpri = '1'.
    append receiver_list.
    General data
    w_object_hd_change-objla = sy-langu.
    w_object_hd_change-objnam = 'Object name'.
    w_object_hd_change-objsns = 'P'.
    w_object_hd_change-file_ext = 'HTM'. "<--this is important
    Mail subject
    w_object_hd_change-objdes = 'HTML from SAP/ABAP'.
    Mail body
    append 'Message content' to message_content.
    append '<b>How''s this for sending HTML E-mail from SAP?</b>' to
    message_content.
    append '<p>New paragraph</p>' to message_content.
    append '<p>Apostrophe&#8217s</p>' to message_content.
    Call function to send email - SAPConnect needs to be configured
    call function 'SO_OBJECT_SEND'
      exporting
          object_hd_change = w_object_hd_change
          object_type = 'RAW'
          owner = sy-uname
      tables
          objcont = message_content
          receivers = receiver_list.
    2)
    ABAP CODE
    Email ITAB structure
    DATA: BEGIN OF EMAIL_ITAB OCCURS 10.
            INCLUDE STRUCTURE SOLI.
    DATA: END OF EMAIL_ITAB.
    DATA: T_EMAIL LIKE SOOS1-RECEXTNAM.  "EMail distribution list
    CONSTANTS: C_EMAIL_DISTRIBUTION LIKE SOOS1-RECEXTNAM VALUE
               ‘[email protected],[email protected]’.
    Initialization
    REFRESH EMAIL_ITAB.
    Populate data
    EMAIL_ITAB-LINE = ‘Email body text 1’.
    APPEND EMAIL_ITAB.
    EMAIL_ITAB-LINE = ‘Email body text 2’.
    APPEND EMAIL_ITAB.
    T_EMAIL = C_EMAIL_DISTRIBUTION.
    --- EMAIL FUNCTION ---------------------------------------------------
    REQUIRMENTS:
    1) The user running the program needs a valid email address in their
       address portion of tx SU01 under external comms -> SMTP -> internet
       address.
    2) A job called SAP_EMAIL is running with the following parameters:
       Program: RSCONN01  Variant: INT   User: XXX
       This program moves mail from the outbox to the mail server using
       RFC destination: SAP_INTERNET_GATEWAY_SERVER
    INTERFACE:
    1) APPLICATION: Anything
    2) EMAILTITLE:  EMail subject
    3) RECEXTNAM:   EMail distribution lists separated by commas
    4) TEXTTAB:     Internal table for lines of the email message
    EXCEPTIONS:
    Send OK = 0 otherwise there was a problem with the send.
        CALL FUNCTION 'Z_SEND_EMAIL_ITAB'
             EXPORTING
                  APPLICATION = 'EMAIL'
                  EMAILTITLE  = 'Email Subject'
                  RECEXTNAM   = T_EMAIL
             TABLES
                  TEXTTAB     = EMAIL_ITAB
             EXCEPTIONS
                  OTHERS      = 1.
    Function Z_SEND_EMAIL_ITAB
    ""Local interface:
    *"       IMPORTING
    *"             VALUE(APPLICATION) LIKE  SOOD1-OBJNAM
    *"             VALUE(EMAILTITLE) LIKE  SOOD1-OBJDES
    *"             VALUE(RECEXTNAM) LIKE  SOOS1-RECEXTNAM
    *"       TABLES
    *"              TEXTTAB STRUCTURE  SOLI
    *- local data declaration
      DATA: OHD    LIKE SOOD1,
            OID    LIKE SOODK,
            TO_ALL LIKE SONV-FLAG,
            OKEY   LIKE SWOTOBJID-OBJKEY.
      DATA: BEGIN OF RECEIVERS OCCURS 0.
              INCLUDE STRUCTURE SOOS1.
      DATA: END OF RECEIVERS.
    *- fill odh
      CLEAR OHD.
      OHD-OBJLA    = SY-LANGU.
      OHD-OBJNAM   = APPLICATION.
      OHD-OBJDES   = EMAILTITLE.
      OHD-OBJPRI   = 3.
      OHD-OBJSNS   = 'F'.
      OHD-OWNNAM   = SY-UNAME.
    *- send Email
      CONDENSE RECEXTNAM NO-GAPS.
      CHECK RECEXTNAM <> SPACE AND RECEXTNAM CS '@'.
    *- for every individual recipient send an Email
    (see OSS message 0120050409/0000362105/1999)
      WHILE RECEXTNAM CS ','.
        PERFORM INIT_REC TABLES RECEIVERS.
        READ TABLE RECEIVERS INDEX 1.
        RECEIVERS-RECEXTNAM = RECEXTNAM+0(SY-FDPOS).
        ADD 1 TO SY-FDPOS.
        SHIFT RECEXTNAM LEFT BY SY-FDPOS PLACES.
        MODIFY RECEIVERS INDEX 1.
        PERFORM SO_OBJECT_SEND_REC
         TABLES TEXTTAB RECEIVERS
          USING OHD.
      ENDWHILE.
    *- check last recipient in recipient list
      IF RECEXTNAM <> SPACE.
        PERFORM INIT_REC TABLES RECEIVERS.
        READ TABLE RECEIVERS INDEX 1.
        RECEIVERS-RECEXTNAM = RECEXTNAM.
        MODIFY RECEIVERS INDEX 1.
        PERFORM SO_OBJECT_SEND_REC
         TABLES TEXTTAB RECEIVERS
          USING OHD.
      ENDIF.
    ENDFUNCTION.
          FORM SO_OBJECT_SEND_REC                                       *
    FORM  SO_OBJECT_SEND_REC
    TABLES  OBJCONT      STRUCTURE SOLI
            RECEIVERS    STRUCTURE SOOS1
    USING   OBJECT_HD    STRUCTURE SOOD1.
      DATA:   OID     LIKE SOODK,
              TO_ALL  LIKE SONV-FLAG,
              OKEY    LIKE SWOTOBJID-OBJKEY.
      CALL FUNCTION 'SO_OBJECT_SEND'
           EXPORTING
                EXTERN_ADDRESS             = 'X'
                OBJECT_HD_CHANGE           = OBJECT_HD
                OBJECT_TYPE                = 'RAW'
                OUTBOX_FLAG                = 'X'
                SENDER                     = SY-UNAME
           IMPORTING
                OBJECT_ID_NEW              = OID
                SENT_TO_ALL                = TO_ALL
                OFFICE_OBJECT_KEY          = OKEY
           TABLES
                OBJCONT                    = OBJCONT
                RECEIVERS                  = RECEIVERS
           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.
      IF SY-SUBRC <> 0.
        RAISE OTHERS.
      ENDIF.
    ENDFORM.
          FORM INIT_REC                                                 *
    FORM INIT_REC TABLES RECEIVERS STRUCTURE SOOS1.
      CLEAR RECEIVERS.
      REFRESH RECEIVERS.
      MOVE SY-DATUM  TO RECEIVERS-RCDAT .
      MOVE SY-UZEIT  TO RECEIVERS-RCTIM.
      MOVE '1'       TO RECEIVERS-SNDPRI.
      MOVE 'X'       TO RECEIVERS-SNDEX.
      MOVE 'U-'      TO RECEIVERS-RECNAM.
      MOVE 'U'       TO RECEIVERS-RECESC.
      MOVE 'INT'     TO RECEIVERS-SNDART.
      MOVE '5'       TO RECEIVERS-SORTCLASS.
      APPEND RECEIVERS.
    ENDFORM.
    3)
    DATA: OBJPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
      DATA: OBJHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
      DATA: OBJBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: OBJTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: RECLIST   LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
      DATA: DOC_CHNG  LIKE SODOCCHGI1.
      DATA: TAB_LINES LIKE SY-TABIX.
      DATA L_NUM(3).
    Creation of the document to be sent
    File Name
      DOC_CHNG-OBJ_NAME = 'SENDFILE'.
    Mail Subject
      DOC_CHNG-OBJ_DESCR = 'Delivered Mail'.
    Mail Contents
      OBJTXT = 'Object text'.
      APPEND OBJTXT.
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ TABLE OBJTXT INDEX TAB_LINES.
      DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creation of the entry for the compressed document
      CLEAR OBJPACK-TRANSF_BIN.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'.
      APPEND OBJPACK.
    Creation of the document attachment
      LOOP AT ITAB_DATA.
        CONCATENATE ITAB_DATA-PRODUCTOR
                    ITAB_DATA-VBELN
                    ITAB_DATA-POSNR
                    ITAB_DATA-MATNR INTO OBJBIN.
        APPEND OBJBIN.
      ENDLOOP.
      DESCRIBE TABLE OBJBIN LINES TAB_LINES.
      OBJHEAD = 'ORDERS'.
      APPEND OBJHEAD.
    Creation of the entry for the compressed attachment
      OBJPACK-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM   = 1.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM   = TAB_LINES.
      OBJPACK-DOC_TYPE   = 'TXT'.
      OBJPACK-OBJ_NAME   = 'WEBSITE'.
      OBJPACK-OBJ_DESCR  = 'ORDERS.TXT'.
      OBJPACK-DOC_SIZE   = TAB_LINES * 255.
      APPEND OBJPACK.
    Completing the recipient list
    target recipent
      clear RECLIST.
      RECLIST-RECEIVER = '[email protected]'.
      RECLIST-EXPRESS  = 'X'.
      RECLIST-REC_TYPE = 'U'.
      APPEND RECLIST.
    copy recipents
      clear RECLIST.
      RECLIST-RECEIVER = '[email protected]'.
      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.
    ENDFORM.                    " SEND_MAIL
    Thanks & Regards
    Sreeni

  • Email with excel as attachment

    Hi all,
    1)  I have sent a mail with an excel attachment....in that can i make the characters BOLD...just to
    differentiate field names and values...??
    2) can i colour them..??
    Any pointers would be really helpfull...
    Thank you..

    Hi,
    I am trying to send some field in excel format to lotus note as an attachment.
    Can anybody help to do that.
    Thanks & Regards,
    Suresh Babu gade

  • Sending a email with the form attached but no submit Button

    Hi experts,
    I have designed a form in ABAP using the t-code SFP. i Have a button "accept", in the form.
    Now i am calling this form from an executable program and send it to mail with the form attached.
    I am successfully receiving the mail with the form attach.
    Now my requirement is when i open the attached form and click on ACCEPT button, again a mial shud be triggered with the same form attached but no ACCEPT button shud appear on the form.
    I am able to trigger the mail on click of the ACCEPT button and mail is also sent withj the form attached , but the ACCEPT button still exists.
    I have written the following code on click of the button.
    this.presence = "invisible";
    event.target.submitForm();
    Please some expert help me in solving this problem as soon as possible.
    Thanks and Regards,
    Madhu

    Did you get my point hwta i have mentioned? The steps which I have suggested will solve your problem.
    Please add one dummy attribute (One Char length) to the Form interface.
    In the form add one hidden field - SubmitFlag and bind this to the dummy attribute of the interface. Before submit set this flag to Y.
    On form Load check if Submit Flag is Y or not. if it is then hide the button agin.
    This will work fine for you.
    If after implementing this it will not work, send it to my Id [email protected]
    But first i will suggest to try yourself.
    Cheers
    Satya

  • Send a email with a csv attachment - extension not working!!! please help!!

    DataSource fileDataSource = new FileDataSource(SystemServices.REPORTS_LOC+"mortgage/"+"mortgageleads"+sDF.format(yesterdayDate.getTime())+".csv") {
                public String getContentType() {
                   return "text/csv";
    attachmentList.add(fileDataSource);When the file comes into the email box it comes thru as a .txt file which isnt what i want. could someone help me and tell me how u send it as .csv

    the answer
                                            MimeBodyPart attachmentPart = new MimeBodyPart();
                                DataSource fileDataSource = new FileDataSource(fileLocation);
                             attachmentPart.setDataHandler(new DataHandler(fileDataSource));
                             attachmentPart.setFileName(filename);seems setting the name auto sets the mime type!

  • Sending E-mail with Excel format

    HI all,
    I am sending an Email with Excel as attached,the internal table(l_t_objbin) for e-mail content is 225(char) but my records contains more than 255 chars, so i am splitting the record into < 255 char(240) and concadinating as given below...
    INTO l_t_objbin SEPARATED BY con_tab .
        CONCATENATE l_t_objbin con_tab  INTO l_t_objbin .
        APPEND l_t_objbin.
    after doing the above i am getting whole record inot single but the issues is the file in which i am concodinating gets Expanded some extra length ,, i need to Tirm those spaces,,i have tried to use condense but it is not working..please anybody have idea.plz let me know..thx

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

Maybe you are looking for

  • Can Retake Quiz button take me to 3rd question slide of the project?

    Hi, I am happy to join this forum. I hope anyone of you answer my question. I am using captivate 4. I am not storing score onto any LMS. I am developing an e-learning course of 30 slides. First 20 slides are content slides. I have 2 question slides a

  • ITunes deleting and resyncing 200 songs issue

    Every time I sync my iPod Touch, iTunes removes approximately 220 of my songs and then "re-syncs" them onto the iPod. This happens without altering my iTunes library at all. And if I look at the sync bar in iTunes it is always the exact same 200+ son

  • FF 3.6.15 works great, but FF 4.0 crashes/locks after hardware upgrade?

    FF4 worked great on my old system (starting with b.11) but not on my new one. It fails in normal mode as well as safe mode, and on the rare occasion that it runs longer than a second, it locks up so that I have to use the task manager to close it. I

  • Macintosh HD Icon relocation question

    Is there a safer place to put the Hard Drive icon other than on the desktop? It's been in the upper right hand corner of my screen for years but I rarely click on it.  Thanks.

  • EP7 SP11 new behavior with url iview launching external apps

    We have a simple URL iView that we deployed to open Lotus Notes (notes:///bookmark.nsf).  When we use this in EP7 SP10 it launches the external Notes client on the end user's PC and leaves the navigation area of the portal blank white. When we launch