Need to send my spool in HTML format as Email attachment

Hi All,
    Can anyone let me know how to send a HTML attachment in a mail.
I have a ALV Report, when i execute, my report should pick the ALV Report output from spool, and should send a mail with spool output as HTML attachment.
Please explain me how i need to do the above.
Regards
Nanda

Hi Nanda,
You can use 2 reports for this.
In one report just display the ALV..
and in the second report submit this first report  to memory and get it html format and then send it as an email.
Just check this code (instead of alv...this is a normal report that is sent as HTML attachment)
*--Tables
TABLES: VBRK.
                 TYPES DECLARATION                                   *
TYPES: BEGIN OF TY_VBRK,
        KUNAG TYPE KUNAG," Payer Id
       END OF TY_VBRK,
*-- customer details
       BEGIN OF TY_KNA1,
        KUNNR TYPE KUNNR," Customer Id
        NAME1 TYPE NAME1," Customer Name
        ADRNR TYPE ADRNR," Address No
       END OF TY_KNA1,
*-- Mailing details
       BEGIN OF TY_ADDR,
        ADDRNUMBER TYPE AD_ADDRNUM, " Address No
        MAIL_ID TYPE AD_SMTPADR,    " Email Address
       END OF TY_ADDR,
*-- Log details
       BEGIN OF TY_MSG,
        STR1 TYPE AD_SMTPADR, " Email Address
        STR2 TYPE KUNNR,      " Payer Id
        STR3 TYPE NAME1,      " Payer Name
        STR4 TYPE D,          " Date
        STR5 TYPE T,          " Time
       END OF TY_MSG.
             I N T E R N A L  T A B L E S                            *
DATA: RECEPIENTS TYPE TABLE OF AD_SMTPADR, "table for email id's
      LISTOBJECT TYPE TABLE OF ABAPLIST,   "table with displayed list
      HTML TYPE TABLE OF W3HTML,           "html container
      RETURN TYPE TABLE_OF_STRINGS,        "message table
      IT_VBRK TYPE TABLE OF TY_VBRK,       "Billing Details
      IT_KNA1 TYPE TABLE OF TY_KNA1,       "Customer Details
      IT_ADDR TYPE TABLE OF TY_ADDR,       "Mail id
      IT_MSG TYPE TABLE OF TY_MSG.         "Log Details
*-- Structure Declarations
DATA: WA_REC TYPE AD_SMTPADR,
      WA_KNA1 TYPE TY_KNA1,
      WA_ADDR TYPE TY_ADDR,
      WA_MSG TYPE TY_MSG.
      Declarations for Sending mail                                  *
*-- To Create link and add recepients address
DATA: SEND_REQUEST TYPE REF TO CL_BCS.
*-- To Create HTML document
DATA: DOCUMENT TYPE REF TO CL_DOCUMENT_BCS.
*-- To Create Sender Id
DATA: SENDER_ID TYPE REF TO IF_SENDER_BCS.
*-- To Create recepient address
DATA: RECIPIENT TYPE REF TO IF_RECIPIENT_BCS.
*-- To Handle Exceptions
DATA: BCS_EXCEPTION TYPE REF TO CX_BCS.
*-- To check if the mail is sent to all recepients
DATA: SENT_TO_ALL TYPE OS_BOOLEAN.
DATA: CONLENGTHS TYPE SO_OBJ_LEN . "To calculate length of the HTML file
              V A R I A B L E S                                      *
DATA: REPORT TYPE PROGRAMM,    "Report name
      SENDER TYPE AD_SMTPADR,  "Sender Address
      SUBJECT TYPE SO_OBJ_DES. "Subject
DATA: BCS_MESSAGE TYPE STRING ."String to store exceptions
DATA: V_KUNAG TYPE KUNAG.      "Payer Id
DATA: V_MAIL TYPE AD_SMTPADR,  "Mail Address
      V_DATE TYPE ZZBCDATE.    "To Validate Entered Date
             S E L C T I O N - S C R E E N                           *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_ZZBCDA FOR VBRK-ZZBCDAT. "Billing Complete Date
PARAMETERS:     P_MAILFT TYPE AD_SMTPADR,  "Mail id
                P_MAILSC TYPE AD_SMTPADR.  "Mail id
SELECTION-SCREEN END OF BLOCK B1.
                  At Selection Screen                                *
AT SELECTION-SCREEN.
*-- Validate the dates entered
  SELECT ZZBCDAT UP TO 1 ROWS
          FROM VBRK
          INTO V_DATE
          WHERE ZZBCDAT IN S_ZZBCDA.
  ENDSELECT.
  IF SY-SUBRC <> 0.
    MESSAGE E002 WITH 'Dates Not Found In The Given Range'(002).
  ENDIF.
             S T A R T - O F - S E L E C T I O N                     *
  CONCATENATE SY-UNAME '@YAHOO.COM'(003) INTO SENDER.
*-- Populating the Subject Line
  MOVE 'Invoice Due Date Details'(004) TO SUBJECT.
*-- Selecting the Payer Details Based on Input Dates
  SELECT KUNAG
          FROM VBRK
          INTO TABLE IT_VBRK
               WHERE ZZBCDAT IN S_ZZBCDA.
*-- Selecting the Address Number from Customer Master
  SELECT KUNNR
         NAME1
         ADRNR
          FROM KNA1
          INTO TABLE IT_KNA1
               FOR ALL ENTRIES IN IT_VBRK
               WHERE KUNNR = IT_VBRK-KUNAG.
*-- Selecting the Mail Id's
  SELECT ADDRNUMBER
         SMTP_ADDR
          FROM ADR6
          INTO TABLE IT_ADDR
               FOR ALL ENTRIES IN IT_KNA1
               WHERE ADDRNUMBER = IT_KNA1-ADRNR.
*-- Getting all the selected mail Id's
  RECEPIENTS = IT_ADDR[].
  MOVE (your first report name) TO REPORT.
  IF NOT RECEPIENTS[] IS INITIAL .
    LOOP AT IT_KNA1 INTO WA_KNA1.
      AT NEW KUNNR.
        READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_KNA1-KUNNR
                                                          BINARY SEARCH.
        REFRESH RECEPIENTS.
*-- Populating the Recepients Mail Id's for the Particular Kunnr
        LOOP AT IT_ADDR INTO WA_ADDR WHERE ADDRNUMBER = WA_KNA1-ADRNR.
          IF NOT WA_ADDR IS INITIAL.
            TRANSLATE WA_ADDR-MAIL_ID TO UPPER CASE.
            APPEND WA_ADDR-MAIL_ID TO RECEPIENTS.
          ENDIF.
        ENDLOOP.
*-- Appending the mail id's from the input fields when not initial
        IF NOT P_MAILFT IS INITIAL.
          TRANSLATE P_MAILFT TO UPPER CASE.
          APPEND P_MAILFT TO RECEPIENTS.
        ENDIF.
        IF NOT P_MAILSC IS INITIAL.
          TRANSLATE P_MAILSC TO UPPER CASE.
          APPEND P_MAILSC TO RECEPIENTS.
        ENDIF.
*-- Sending the Kunnr while Submitting the Report
        V_KUNAG = WA_KNA1-KUNNR.
        TRANSLATE REPORT TO UPPER CASE .
*--Submitting the Report Exporting the List to Memory
        SUBMIT (REPORT) WITH S_ZZBCDA IN S_ZZBCDA
                        WITH P_KUNAG = V_KUNAG
                         EXPORTING LIST TO MEMORY AND RETURN.
        CLEAR: LISTOBJECT , HTML .
        REFRESH : LISTOBJECT, HTML .
*-- Calling the Fn Module to get the list from the Memory
        CALL FUNCTION 'LIST_FROM_MEMORY'
          TABLES
            LISTOBJECT = LISTOBJECT.
*-- Calling Fn Module to get the List in HTML Format
        CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
          EXPORTING
            REPORT_NAME = REPORT
          TABLES
            HTML        = HTML
            LISTOBJECT  = LISTOBJECT.
*-- Getting the Size of the Html Document
        DATA: V_LINES TYPE I.
        DESCRIBE TABLE HTML LINES V_LINES.
        CLEAR CONLENGTHS .
        CONLENGTHS = V_LINES * 255.
        TRY.
            CLEAR SEND_REQUEST .
            SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
            CLEAR DOCUMENT .
*-- Creating the Document
            DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
            I_TYPE = 'HTM'
            I_TEXT = HTML
            I_LENGTH = CONLENGTHS
            I_SUBJECT = SUBJECT ).
*-- add document to send request
            CALL METHOD SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
            CLEAR SENDER_ID .
*-- Creating the internet address for the sender id.
      SENDER_ID = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( SENDER ).
            CALL METHOD SEND_REQUEST->SET_SENDER
              EXPORTING
                I_SENDER = SENDER_ID.
            CLEAR WA_REC .
*-- Creating the Recepients address
            LOOP AT RECEPIENTS INTO WA_REC .
              CLEAR RECIPIENT .
              RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
              WA_REC ).
add recipient with its respective attributes to send request
              CALL METHOD SEND_REQUEST->ADD_RECIPIENT
                EXPORTING
                  I_RECIPIENT = RECIPIENT
                  I_EXPRESS   = 'X'.
            ENDLOOP .
            CALL METHOD SEND_REQUEST->SET_STATUS_ATTRIBUTES
              EXPORTING
                I_REQUESTED_STATUS = 'E'
                I_STATUS_MAIL      = 'E'.
            CALL METHOD SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
*-- Sending the Document
            CALL METHOD SEND_REQUEST->SEND(
            EXPORTING
            I_WITH_ERROR_SCREEN = 'X'
            RECEIVING
            RESULT = SENT_TO_ALL ).
            IF SENT_TO_ALL = 'X'.
*-- Getting the details to display the Job Log
              LOOP AT RECEPIENTS INTO V_MAIL.
                WA_MSG-STR1 = V_MAIL.
                WA_MSG-STR2 = WA_KNA1-KUNNR.
                WA_MSG-STR3 = WA_KNA1-NAME1.
                WA_MSG-STR4 = SY-DATUM.
                WA_MSG-STR5 = SY-UZEIT.
                APPEND WA_MSG TO IT_MSG.
              ENDLOOP.
            ELSE.
              APPEND 'Mail not sent'(005)  TO RETURN.
            ENDIF.
            COMMIT WORK.
          CATCH CX_BCS INTO BCS_EXCEPTION.
            BCS_MESSAGE = BCS_EXCEPTION->GET_TEXT( ).
            APPEND BCS_MESSAGE TO RETURN .
            EXIT.
        ENDTRY.
      ENDAT.
    ENDLOOP.
  ELSE .
    APPEND 'Specify email address for sending'(006) TO RETURN .
  ENDIF .
                 E N D - O F - S E L E C T I O N                     *
END-OF-SELECTION.
*-- Displaying the Job Log
  FORMAT COLOR 1 INTENSIFIED ON.
  WRITE:/        SY-ULINE(121),
            (40) 'Mail Sent to'(007),
                 SY-VLINE,
            (12) 'Payer Id'(008),
                 SY-VLINE,
            (35) 'Payer Name'(009),
                 SY-VLINE,
            (10) 'Sent Date'(010),
                 SY-VLINE,
            (10) 'Sent Time'(011),
                 SY-VLINE,
                 SY-ULINE(121).
  LOOP AT IT_MSG INTO WA_MSG.
    FORMAT COLOR 2 INTENSIFIED ON.
    WRITE:/         SY-ULINE(121),
               (40) WA_MSG-STR1,
                    SY-VLINE,
               (12) WA_MSG-STR2,
                    SY-VLINE,
               (35) WA_MSG-STR3,
                    SY-VLINE,
               (10) WA_MSG-STR4  DD/MM/YYYY,
                    SY-VLINE,
               (10) WA_MSG-STR5  USING EDIT MASK '__:__:__',
                    SY-VLINE,
                    SY-ULINE(121).
  ENDLOOP.

Similar Messages

  • Convert the spool to xls format and email through attachment to the user

    Hi all,
    When I execute a report in background, I get spool. I need to convert the spool to xls format and email through attachment to the user.The xls file should not be saved on local system.
    If I use the Spool Recepient tab in SM37 it mails the spool list as .txt file to the mail receipient. But I need to send it as an .xls file.
    Can any one help me on this

    Did you get the solution? i have the same problem.

  • Error in converting Spool to HTML format.

    Hi Gurus,
    I am reading SPool and converting that into HTML formt. Please do find below code for the same.
    Submit report to convert the spool to HTML format
      SUBMIT rspolst2 EXPORTING LIST TO MEMORY AND RETURN
      WITH rqident = p_spoolno.
      CALL FUNCTION 'LIST_FROM_MEMORY'
        TABLES
          listobject = gt_listobj
        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.
    Convert the spool to HTML format
      CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
       EXPORTING
       REPORT_NAME         =
         template_name       = 'WEBREPORTING_REPORT'
        TABLES
          html                = p_html_tab
          listobject          = gt_listobj.
    >>>>>>>>>>>>>>>>>>>
    And i send p_html_tab as attachement to email.
    When I opened the attachement, i can view only half page in htm.
    How can i get the full page in htm.

    First convert the spool to internal table by using FM
    RSPO_RETURN_ABAP_SPOOLJOB
    Next from internal table to HTML....
    Link: /people/rammanohar.tiwari/blog/2006/01/29/abap-utility-print-screen-to-html
    or try the following
    Please try the follwoing:
    1. define HTML internal table with ref to type W3HTML
    2. download it as BIN type and give total lenght of the strings as a parameter in the down load.
    See the code extract below:
    describe table html lines entries.
    read table html into w_html index entries.
    size = ( entries - 1 ) * 255 + strlen( w_html ).
    concatenate p_path file into file.
    call function 'WS_DOWNLOAD'
    exporting
    bin_filesize = size
    filename = file
    filetype = 'BIN'
    tables
    data_tab = html

  • Send e-mail in HTML-format with attachment

    Does function SO_OBJECT_SEND allow to send e-mail with attachment?
    Does function SO_DOCUMENT_SEND_API1 allow to send e-mail in HTML format?

    Hi SS
    See if you can understand this sample program
    PARAMETERS: po_email TYPE AD_SMTPADR LOWER CASE.
    DATA: li_objcont TYPE STANDARD TABLE OF solisti1,
    li_reclist TYPE STANDARD TABLE OF somlreci1,
    li_objpack TYPE STANDARD TABLE OF sopcklsti1,
    li_objhead TYPE STANDARD TABLE OF solisti1,
    li_content TYPE STANDARD TABLE OF solisti1,
    lwa_objcont TYPE solisti1,
    lwa_reclist TYPE somlreci1,
    lwa_objpack TYPE sopcklsti1,
    lwa_objhead TYPE solisti1,
    lwa_content TYPE solisti1,
    lwa_doc TYPE sodocchgi1,
    l_lines TYPE i.
    REFRESH: li_objcont[], li_reclist[],
    li_objpack[], li_objhead[],
    li_content[].
    CLEAR: lwa_objcont, lwa_reclist,
    lwa_objpack, lwa_objhead,
    lwa_content, lwa_doc.
    MOVE '<body>' TO lwa_objcont.
    APPEND lwa_objcont TO li_objcont.
    MOVE '<p>' TO lwa_objcont.
    APPEND lwa_objcont TO li_objcont.
    MOVE 'This is a sample HTML content from test program' TO lwa_objcont.
    APPEND lwa_objcont TO li_objcont.
    MOVE '</p>' TO lwa_objcont.
    APPEND lwa_objcont TO li_objcont.
    MOVE '</body>' TO lwa_objcont.
    APPEND lwa_objcont TO li_objcont.
    lwa_reclist-receiver = po_email.
    lwa_reclist-rec_type = 'U'.
    APPEND lwa_reclist TO li_reclist.
    lwa_objhead = 'test.htm'.
    APPEND lwa_objhead TO li_objhead.
    lwa_content = 'Please find attached document for more details'.
    APPEND lwa_content TO li_content.
    CLEAR l_lines.
    DESCRIBE TABLE li_content LINES l_lines.
    READ TABLE li_content INTO lwa_content INDEX l_lines.
    lwa_doc-doc_size = ( l_lines - 1 ) * 255 + STRLEN( lwa_content ).
    lwa_doc-obj_langu = 'E'.
    lwa_doc-obj_name = 'Test HTML file'.
    lwa_doc-obj_descr = 'Test HTML file'.
    CLEAR lwa_objpack-transf_bin.
    lwa_objpack-head_start = 1.
    lwa_objpack-head_num = 0.
    lwa_objpack-body_start = 1.
    lwa_objpack-body_num = l_lines.
    lwa_objpack-doc_type = 'RAW'.
    APPEND lwa_objpack TO li_objpack.
    CLEAR: lwa_objpack, l_lines.
    DESCRIBE TABLE li_objcont LINES l_lines.
    READ TABLE li_objcont INTO lwa_objcont INDEX l_lines.
    lwa_objpack-doc_size = ( l_lines - 1 ) * 255 + STRLEN( lwa_objcont ).
    lwa_objpack-transf_bin = 'X'.
    lwa_objpack-head_start = 1.
    lwa_objpack-head_num = 0.
    lwa_objpack-body_start = 1.
    lwa_objpack-body_num = l_lines.
    lwa_objpack-doc_type = 'HTM' .
    lwa_objpack-obj_name = 'Test HTML file'.
    lwa_objpack-obj_descr = 'Test HTML file'.
    APPEND lwa_objpack TO li_objpack.
    *Sending the mail
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = lwa_doc
    put_in_outbox = 'X'
    TABLES
    packing_list = li_objpack
    object_header = li_objhead
    contents_bin = li_objcont
    contents_txt = li_content
    receivers = li_reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    operation_no_authorization = 4
    OTHERS = 99.
    IF sy-subrc NE 0.
    WRITE:/ 'Document sending failed'.
    ELSE.
    WRITE:/ 'Document successfully sent'.
    COMMIT WORK.
    ENDIF.
    This should give you all you need to know to send an HTML file.
    Thanks buddy

  • I need to send sm37 Spool Report Automatically to one or more user ids.

    Hai Gurus,
    I need to send sm37 Spool Report Automatically to one or more user ids.
    Kindly guide me

    Thanks.. .
    is it possible to create Many distribution list for each & every Spool Report ?
    I mean, Can i create separate distribution list for each Reports ?. EX: ME2N Report.
    Edited by: Swetha SAP Girl on Jul 6, 2009 10:11 AM

  • Need send the sapscript in HTML format.

    Hi,
      I need to email the SAPScript form in HTML format to external user i mean customer.
       Please help me how to send SAP data in email as HTML data with or with out script is very helpful to me .
    Regards,
    Naidu

    Hi,
      I need to email the SAPScript form in HTML format to external user i mean customer.
       Please help me how to send SAP data in email as HTML data with or with out script is very helpful to me .
    Regards,
    Naidu

  • How to send a mail in html format from a send mail workflow node ?

    Dear all,
    Do you know if it is possible to send an e-mail in HTML format (instead of RAW) from a "send mail" node in a workflow ?  ... if "yes", please, let me know.
    (I need to do that because I want to use the "href" tag to insert an hyperlink inside the e-mail)
    - I haven't found any parameter to specify the format of the e-mail.
    - Inside SCOT I tried to change the parameters for the SMTP node... without success.
    - I don't want to use a task calling the FM SO_OBJECT_SEND.
    Nicolas

    Hi Nicolas!
    Have you tried to set "Output Format" for "RAW Text" to HTM in SCOT.
    If HTM is missing in your dropdown-list, you could check out table SXCONVERT2. Copy the line with category T/format TXT, and change the format from TXT to HTM. The existing function
    SX_OBJECT_CONVERT__T.TXT does not need to be changed. Now you should be able to choose HTM in SCOT. You will probably need som HTML-tags in your text to make it look good.
    Hope this helps!
    Regards
    Geir

  • Send email in html format with pdf attachment

    I am trying to send an email out of SAP using an abap program in the html format with a pdf attachment. I am using the function module -SO_DOCUMENT_SEND_API1. I noticed that when i specify the body type of the message as 'RAW' I get to see the pdf attachments however when i switch it to 'HTM' I loose the attachment in the email generated. Can anyone please help me in solving this problem. Thanks!

      ld_email                 = p_email. "All email IDs
      ld_mtitle                 = 'Bank Statement'.
      ld_format                = 'PDF'. "Attachment Format
      ld_attdescription      = 'Statement'.
      ld_attfilename          = p_filename. "Name of file
      ld_sender_address      = p_sender_address. "Sender mail address
      ld_sender_address_type = p_sender_addres_type. "INT - Internet
    * 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 . "Description
      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. "Description
      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 = 'HTM'. " THis is for BODY of mail 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.

  • Sending E-mail in HTML format

    Hello All,
    I have to send e-mail to a customer but the e-mail should be sent out in an HTML Format which would look good.. 
    I know the FM to send the e-mail but how to build the body in the HTML format because i have a big bunch of text.
    Is there any way to create a HTML template in SMW0 and read the same using any function modules to build the body like given below...
    Eg:
    Dear Customer
    Multiples lines of text....
    Your suggestions are highly appreciated.
    Regards,
    Krishnakumar

    Try this way
      submit yXXXXX0001 exporting list to memory " Write a report for HTML body and properly format
                                                                       " and submit the report to list to memory
               with p_docno = xdocno
               and return.
      call function 'LIST_FROM_MEMORY'
        tables
          listobject = report_list
        exceptions
          not_found  = 1
          others     = 2.
      call function 'WWW_HTML_FROM_LISTOBJECT'
        exporting
          template_name = 'WEBREPORTING_REPORT'
        tables
          html          = report_html
          listobject    = report_list.
    Here internal table report_html contains body for HTML mail in HTML tags

  • Need to sent alv output as html or as pdf attachment in mail

    +Hello
    I want to send an ALV output as attachement in html or as pdf format. how to do that? line size is greater than 600(nearly 40 fields).
    +please help me in this query.
    Regards
    Guruvayurappan
    Moderator Message: Please search before posting your question. Thread locked.
    Edited by: Suhas Saha on Dec 29, 2011 4:57 PM

    Hi,
    For sending the ALV output as PDF attachment, you can create a spool (proper page size in print parameters) and convert the spool to PDF using the FM CONVERT_ABAPSPOOLJOB_2_PDF and then send the same as attachment in mail.
    For send the data as HTML attachment, try the below FMs
    WWW_ITAB_TO_HTML_HEADERS & WWW_ITAB_TO_HTML_LAYOUT to create the HTML layout
    WWW_ITAB_TO_HTML to create the HTML for the actual data.
    Hope this helps you.
    Regards,
    Sachinkumar Mehta

  • HTML Format via Email

    When sending output via email in HTML format (from rtf template), all the formating is lost, layout just expands horizontally.
    Output is correct when displayed in pdf format.
    Also occurs when previewing the output.
    Further information:
    This is purely a custom rtf template created for remittance report. In the rtf template we have used the filler, we have kept many conditions like if the data spills over to next page based on number of lines,and if the number of data lines is less then also it should align and fit to the table /page etc.
    If we remove the filler the output will shrink to half page in HTML page and WE DO NOT want this kind of report output. We need the report output in HTML which should fir to paper size(A4 size) even we have less number of data rows.
    Any assistance would be appreciated.
    Thanks
    Sarah

    Thanks for your response.
    The customer has updated with the following:
    The problem here is the standard program "IBY_FD_SRA_FORMAT module: Send Separate Remittance Advices" sets the output type to HTML if the remittance advice delivery method is "MAIL". Below is the extract from the log file of the program "IBY_FD_SRA_FORMAT module: Send Separate Remittance Advices"
    ******** EXTRACT BEGIN ********
    Since the delivery method is EMAIL, the XML Publisher output type is set to be html.
    ********* EXTRACT END *********
    This causes the following issue: -
    The concurrent program ends without generating a pdf output and hence cannot be emailed out as a pdf document.
    Action required from you: -
    [1] Ensure that the standard program does not default the output type to HTML for email. This should be PDF instead.
    [2] Ensure that IBY XDO Delivery, sends the PDF output as an attachment.

  • Sending content in an html page via email as body

    Hi
    I am really in need of a prompt help for sending a web page which contains some html content as an email body.
    I really have no clue about this.
    I have tried searching in google but could not find any thing in java.
    I have everything ready for sending an email, i.e. to, from and subject.
    The only thing i need is the content from an html.
    I can set the content type as text/html.
    I need some help on content Id and content.
    Any quick help is really appreciated.
    Thank you.

    I have tried searching in google but could not find
    any thing in java.You actually didn't. Go take a look:
    http://java.sun.com/developer/EJTechTips/2004/tt0426.html#1

  • HTML Formatting Auto Email messages

    We have a scenario, when we provide a status update to an SR. The activity description is sent out as an automatic email. Workflow is working fine issue is automatic email is in Text format instead of an HTML format. Reason why I need an HTML format is in the description there could be a link to a web page. This link appears as text instead of a Hyperlink.
    CRMOD Support states this as an enhancement - I was wondering if anyone has created any workarounds for this.
    Thanks

    I dont believe there is a workaround for this as the emails are sent as plain text email. This has been highlighted as a request from customers i asked them if EMOD could be used in workflow which would be great for both internal and external customers.

  • Need to send the zip file to mail as an attachment

    i want to pick the zip file which consists some 2,3 files inside it. and send as it is to mail as an attachment.what i did is
    i have taken one zip file,,, "testing.zip" inside it i have "test1.txt" & "test2.csv"
    i created sender CC ,,in that i used module payloadzipbean and  unzipped and called the file adapter.. created reciever CC as mail ..used same payload module now here i zipped all the payloads.
    Result..i see the attachment coming as "test1.txt.zip" ..here i can see inside this zipfile my original file names as "test1.txt"&"test2.csv" as i enabled ASMA in both CC.
    issues:i am unable to get the original file name like "testing.zip" ,,
    can anyone help me in this.
    Regards,
    Loordh

    Hi  all,
    as i posted last time my requirement ,i am going with java mapping for my scenario. i am using this code .
    http://wiki.sdn.sap.com/wiki/display/XI/Dynamicfilenameforpass-through+scenario
    this is working perfect for zip file  (file to file) scenario. but my scenario is file to mail ..as i need to send this to mail package there it is throwing error.i am getting  "zip file name as attachment properly but when  i try to  open it is giving error in zip file." this is what i modied code ..i am able to see my messge in sender CC and reciever CC..any java experts please help on this.
    try {
    // create XML structure of mail package
    String output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    + "<ns:Mail xmlns:ns=\"http://sap.com/xi/XI/Mail/30\">"
    + "<Subject>" + mailSubject + "</Subject>"
    + "<From>" + mailSender + "</From>"
    + "<To>" + mailReceiver + "</To>"
    + "<Content_Type>multipart/mixed; boundary=\"" + boundary + "\"</Content_Type>"
    + "<Content>";
    out.write(output.getBytes());
    // create the declaration of the MIME parts
    //First part
    output = "--" + boundary + CRLF
    + "Content-Type: text/plain; charset=UTF-8" + CRLF
    //+ "Content-Transfer-Encoding: 8bit" + CRLF
    + "Content-Disposition: inline" + CRLF + CRLF
    + mailContent + CRLF
    //Second part
    + "--" + boundary + CRLF
    + "Content-Type: Application/zip; name=" + attachmentName + CRLF
    //+ "Content-Transfer-Encoding: base64" + CRLF
    + "Content-Disposition: attachment; filename=" + attachmentName + CRLF + CRLF;
    out.write(output.getBytes());
    //Source is taken as attachment
    copySource(in, out);
    out.write("</Content></ns:Mail>".getBytes());
    } catch (IOException e) {
    throw new StreamTransformationException(e.getMessage());
    protected static void copySource(InputStream in, OutputStream out)
    throws IOException {
    byte[] bbuf = new bytehttp://in.available();
    int bblen = in.read(bbuf);
    if (!(bblen < 0)) {
    //String sbuf = new String(bbuf);
    //String encoded = Base64.encode(sbuf);
    // replace all control characters with escape sequences
    //sbuf = sbuf.replaceAll("&", "&");
    //sbuf = sbuf.replaceAll("\"", """);
    //sbuf = sbuf.replaceAll("'", "&apos;");
    //sbuf = sbuf.replaceAll("<"<");
    //sbuf = sbuf.replaceAll(">", ">");
    out.write(bbuf);}}

  • I want to send my output of report as an email attachment

    i am having internal table contains values.
    i want that output should be send as an email attachment
    to email id given in selection screen.
    help me how to pass that internal table to the parameters
    of SO_DOCUMENT_SEND_API1 function module
    should i call any function modules to format my internal table to get as an attachment in email.
    help me its urgent..

    *& Report  ZEMAIL_ATTACH                                               *
    *& Example of sending external email via SAPCONNECT                    *
    REPORT  ZEMAIL_ATTACH                   .
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    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,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
    *   Retrieve sample data from table ekpo
      PERFORM data_retrieval.
    *   Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    * 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 p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
    *   Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
    *       Build data table for .xls document
    FORM build_xls_data_table.
      CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                 con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
    *    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
    *    con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
        CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
                    wa_charekpo-aedat wa_charekpo-matnr
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       Send email
    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.
      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.
      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[] = 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.
      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.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
    *       Instructs mail send program for SAPCONNECT to send email.
    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
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
    *        Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.
                       " POPULATE_EMAIL_MESSAGE_BODY

Maybe you are looking for

  • Web application and Scanner

    Web application (ADF-application) and Scanner (device that optically scans images, printed text) how to implement a scan from a web application and the ability to preview the scanned document (in the ADF-application) before uploading to the server.

  • BootCamp no longer shows up in Startup after Partition Changes

    I recently tried to make a new Partition on my Hard Drive, a exFAT one so both my Windows and my Mac could use it - however that has since caused my BootCamp to disappear from the startup disk selection page. So I tried to reverse this by deleting th

  • BI JDBC connection failure with MS SQL 2005 - but Portal JDBC is working

    I am a portal novice. I wanted to get tables in the visual composer. so i created the protal jdbc connection to MS SQL 2005. which is working fine. Later i found i need BI jdbc for retreving tables from sql server. when i followed all the steps in th

  • How to get a proper week number and MATCHING year number

    Java classes such as SimpleDateFormat offer convenient means to find out the correct week number of a given date. Week numbering is locale specific and not always intuitive. For example, Dec 31, 2001 is in week 1 of 2002 in locales where a week start

  • Trouble with cut and paste password for wireless network

    Command - C, Command-V did not let me paste wireless password from text edit. Any suggestions as to why? I was able to do so with right click.