ABAP send external email

I use FM SO_OBJECT_SEND to send external email in my Z program but the output always in attachment format, depend on the format i specified (pdf,htm,txt,xls). I want the output to be in standard email body. How to do it?

Hi,
Can you please send your code or check if you are passing att_cont parameter in your function module. I would suggest you to use SO_NEW_DOCUMENT_SEND_API1 function module to send mail.
Also find the code below for your reference.
REPORT  z_test_email_sending.
DATA:  t_reclist TYPE TABLE OF somlreci1,
      wa_receiver LIKE LINE OF t_reclist,
      objcont TYPE TABLE OF solisti1,
     subject TYPE TABLE OF solisti1,
     objline TYPE solisti1,
      w_line_count   TYPE i,
        doc_chng TYPE sodocchgi1,
        offset type i.
CONSTANTS c_sep  TYPE c VALUE '|'.
DATA : BEGIN OF mail_line OCCURS 0,
      sep0,
      model_year(6),
      sep1,
      mf(4),
      sep2,
      type(5),
      sep3,
      variant(14),
      sep4,
      kitype(5),
      sep5,
      option(8),
      sep6,
      color(8),
      sep7,
      uph(11),
      sep8,
      struc_week(10),
      sep9,
    END OF mail_line.
*construct the message and the e-mail
wa_receiver-receiver = receivers mail id.
* Email Subject
doc_chng-obj_name = 'test mail'.
MOVE 'Cost Error from SAP' TO doc_chng-obj_descr.
doc_chng-obj_langu = sy-langu.
*    doc_chng-SENSITIVTY = 'P'.
* Email body
CLEAR objline.
CONCATENATE 'This is an automatically generated email'
'Please do not reply to this email.'
INTO   objline SEPARATED BY space.
APPEND objline TO objcont.
CLEAR objline.
APPEND objline TO objcont.
CONCATENATE 'Cost errors in SAP as on' sy-datum INTO
objline SEPARATED BY space.
APPEND objline TO objcont.
CLEAR objline.
CLEAR objline.
APPEND objline TO objcont.
* horizontal line at beginning of records
DO 80 TIMES.
  IF sy-index = 1.
*   objline+sy-index(1) = ' '.
    continue.
  ELSE.
    offset = sy-index - 1.
    objline+offset(1) = '-'.
  ENDIF.
ENDDO.
clear offset.
APPEND objline TO objcont.
CLEAR objline.
mail_line-sep0 = c_sep.
mail_line-model_year = 'Model Yr'.
mail_line-sep1 = c_sep.
mail_line-mf = 'Mf'.
mail_line-sep2 = c_sep.
mail_line-type = 'Type'.
mail_line-sep3 = c_sep.
mail_line-variant = 'Variant'.
mail_line-sep4 = c_sep.
mail_line-kitype = 'Ki-type'.
mail_line-sep5 = c_sep.
mail_line-option = 'Option'.
mail_line-sep6 = c_sep.
mail_line-color = 'Color'.
mail_line-sep7 = c_sep.
mail_line-uph = 'Upholstery'.
mail_line-sep8 = c_sep.
mail_line-struc_week = 'Str_week'.
mail_line-sep9 = c_sep.
MOVE mail_line TO objline.
APPEND objline TO objcont.
CLEAR mail_line.
CLEAR objline.
* horizontal line at beginning of records
*horizontal line at beginning of records
DO 80 TIMES.
  IF sy-index = 1.
*   objline+sy-index(1) = ' '.
    continue.
  ELSE.
    offset = sy-index - 1.
    objline+offset(1) = '-'.
  ENDIF.
ENDDO.
clear offset.
APPEND objline TO objcont.CLEAR objline.
DO 5 TIMES.
  mail_line-sep0 = c_sep.
  mail_line-model_year = 'xxxx'.
  mail_line-sep1 = c_sep.
  mail_line-mf = 'xxx'.
  mail_line-sep2 = c_sep.
  mail_line-type = 'xxx'.
  mail_line-sep3 = c_sep.
  mail_line-variant = 'xxxx xxxxx'.
  mail_line-sep4 = c_sep.
  mail_line-kitype = 'xxx'.
  mail_line-sep5 = c_sep.
  mail_line-option = 'xxxxxx'.
  mail_line-sep6 = c_sep.
  mail_line-color = 'xxxxxx'.
  mail_line-sep7 = c_sep.
  mail_line-uph = 'xxxxxx'.
  mail_line-sep8 = c_sep.
  mail_line-struc_week = 'xxxxxx'.
  mail_line-sep9 = c_sep.
  MOVE mail_line TO objline.
  APPEND objline TO objcont.
ENDDO.
CLEAR objline.
*horizontal line at beginning of records
DO 80 TIMES.
  IF sy-index = 1.
*   objline+sy-index(1) = ' '.
    continue.
  ELSE.
    offset = sy-index - 1.
    objline+offset(1) = '-'.
  ENDIF.
ENDDO.
clear offset.
APPEND objline TO objcont.
CLEAR objline.
wa_receiver-rec_type = 'U'.
wa_receiver-com_type = 'INT'.
APPEND wa_receiver TO t_reclist.
*   size
DESCRIBE TABLE objcont LINES w_line_count.
READ TABLE objcont INDEX w_line_count INTO objline.
doc_chng-doc_size = ( w_line_count - 1 ) * 255 +
                       STRLEN( objline ).
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
              EXPORTING
                document_data              = doc_chng
                document_type              = 'RAW'
*                  put_in_outbox              = ' '
                commit_work                = 'X'
              TABLES
*                  object_header             = subject
                object_content             = objcont
                receivers                  = t_reclist
              EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                operation_no_authorization = 4
                OTHERS                     = 9.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
KR Jaideep,

Similar Messages

  • To send external email from ABAP

    How to send external email from ABAP Program and what are the settings to be done for the same ?

    Please check..
    Sending External email through SAP
    What is the FM for sending the external email through SAP by attaching layout set  to it?
    These are the FM for sending external email :-
    SO_DOCUMENT_SEND_API1 
    SAPoffice: Send new document with attachments via RFC 
    SO_NEW_DOCUMENT_ATT_SEND_API1
    (In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)
    SAPoffice: Send new document with attachments via RFC 
    Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject. 
    SO_NEW_DOCUMENT_SEND_API1 
    SAPoffice: Send new document 
    How to send a report to an external mail-id?
    Try this sample code :-
    REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.
    DATA : BEGIN OF ITAB OCCURS 0,
    PERNR LIKE PA0001-PERNR,
    ENAME LIKE PA0001-ENAME,
    END OF ITAB.
    DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
    receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
    packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
    listobject LIKE abaplist OCCURS 10,
    compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
    w_object_hd_change LIKE sood1,
    compressed_size LIKE sy-index.
    START-OF-SELECTION.
    SELECT PERNR ENAME
    INTO CORRESPONDING FIELDS OF TABLE ITAB
    FROM PA0001
    WHERE PERNR < 50.
    LOOP AT ITAB.
    WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
    SY-VLINE.
    ENDLOOP.
    Receivers
    receiver_list-recextnam = '[email protected]'. "-->
    EMAIL ADDRESS
    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'.
    Mail subject
    w_object_hd_change-objdes = 'Message subject'.
    Mail body
    APPEND 'Message content' TO message_content.
    Attachment
    CALL FUNCTION 'SAVE_LIST'
    EXPORTING
    list_index = '0'
    TABLES
    listobject = listobject.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    compressed_size = compressed_size
    TABLES
    in = listobject
    out = compressed_attachment.
    DESCRIBE TABLE compressed_attachment.
    CLEAR packing_list.
    packing_list-transf_bin = 'X'.
    packing_list-head_start = 0.
    packing_list-head_num = 0.
    packing_list-body_start = 1.
    packing_list-body_num = sy-tfill.
    packing_list-objtp = 'ALI'.
    packing_list-objnam = 'Object name'.
    packing_list-objdes = 'Attachment description'.
    packing_list-objlen = compressed_size.
    APPEND packing_list.
    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
    packing_list = packing_list
    att_cont = compressed_attachment.

  • Need to send external email with attachment for workflow 20000075

    Hello Everyone,
    I am new to W/F, I Need to send external email with attachment for PO Release W/F 20000075. Currently Work item is being sent to SAP inbox of required user based on PO Release strategy configuration in SPRO. I tried to create Send mail step after PO release event but I am not sure how to arrive at Recipient type in send mail step(the mail should be sent to person in the release strategy). Everything looks fine all I need to do is to send external email with attachment instead of sending work item into SAP inbox.
    Your help will be highly appreciated.
    Thanks.

    You can use extended notifications to send an e-mail message with a link to the workitem. Search for extended notifications in SDN.
    Regards,
    Martin

  • Sending external email via SAPCONNECT

    Hi all,
    I want to know how to send external email through sap.
    Thanks in advance,
    Manosh.

    HI,
    Try this  code:
    *& Report  ZSENDEMAIL                                                  *
    *& Example of sending external email via SAPCONNECT                    *
    REPORT  zsendemail                    .
    PARAMETERS: psubject(40) type c default  'Hello',
                p_email(40)   type c default '[email protected]' .
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Perform populate_message_table.
    *Send email message, although is not sent from SAP until mail send
    *program has been executed(rsconn01)
    PERFORM send_email_message.
    *Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *&      Form  POPULATE_MESSAGE_TABLE
          Adds text to email text table
    form populate_message_table.
      Append 'Email line 1' to it_message.
      Append 'Email line 2' to it_message.
      Append 'Email line 3' to it_message.
      Append 'Email line 4' to it_message.
    endform.                    " POPULATE_MESSAGE_TABLE
    *&      Form  SEND_EMAIL_MESSAGE
          Send email message
    form send_email_message.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      gd_doc_data-obj_langu = sy-langu.
      gd_doc_data-obj_name  = 'SAPRPT'.
      gd_doc_data-obj_descr = psubject.
      gd_doc_data-sensitivty = 'F'.
    Describe the body of the message
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    Add the recipients email address
      clear it_receivers.
      refresh it_receivers.
      it_receivers-receiver = p_email.
      it_receivers-rec_type = 'U'.
      it_receivers-com_type = 'INT'.
      it_receivers-notif_del = 'X'.
      it_receivers-notif_ndel = 'X'.
      append it_receivers.
    Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_txt               = it_message
                receivers                  = it_receivers
           exceptions
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                others                     = 8.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.
    endform.                    " SEND_EMAIL_MESSAGE
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = 'X'
                        and return.
      endif.
    endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    Reward points if found helpful....
    Cheers,
    Chandra Sekhar.

  • Please help in senplease help in smartform send external email send.

    hii all,
    pleaseeeeeeeee help in sending external email in smartform print program.
    i need for RLB_INVOICE order confirmation to send thru email.
    what to code in ZRLN_INVOICE . i copied RLB_INVOICE in zprog.
    so  what rthe changes i need to code in driver program?
    pleaseeeeeeee help with sample coding..

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

  • Sending external email from SAP with following requirements...

    Hi All,
           I need to send external emails from SAP by meeting following requirements.
    1) With subject line more than 100 characters.
    2) No attachments, only body which has specific format (blueprint/layout) and would be amended often, hence code shouldn't be touched during amendments.
    3) Should be able to know the success/failure of mail sending at program level.

    Hi,
    The code below demonstrates how to send an email to an external email address
    *& Report  ZSENDEMAIL                                                  *
    *& Example of sending external email via SAPCONNECT                    *
    REPORT  zsendemail                    .
    PARAMETERS: psubject(40) type c default  'Hello',
                p_email(40)   type c default '[email protected]' .
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Perform populate_message_table.
    *Send email message, although is not sent from SAP until mail send
    *program has been executed(rsconn01)
    PERFORM send_email_message.
    *Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *&      Form  POPULATE_MESSAGE_TABLE
          Adds text to email text table
    form populate_message_table.
      Append 'Email line 1' to it_message.
      Append 'Email line 2' to it_message.
      Append 'Email line 3' to it_message.
      Append 'Email line 4' to it_message.
    endform.                    " POPULATE_MESSAGE_TABLE
    *&      Form  SEND_EMAIL_MESSAGE
          Send email message
    form send_email_message.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      gd_doc_data-obj_langu = sy-langu.
      gd_doc_data-obj_name  = 'SAPRPT'.
      gd_doc_data-obj_descr = psubject.
      gd_doc_data-sensitivty = 'F'.
    Describe the body of the message
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    Add the recipients email address
      clear it_receivers.
      refresh it_receivers.
      it_receivers-receiver = p_email.
      it_receivers-rec_type = 'U'.
      it_receivers-com_type = 'INT'.
      it_receivers-notif_del = 'X'.
      it_receivers-notif_ndel = 'X'.
      append it_receivers.
    Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_txt               = it_message
                receivers                  = it_receivers
           exceptions
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                others                     = 8.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.
    endform.                    " SEND_EMAIL_MESSAGE
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = 'X'
                        and return.
      endif.
    endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    Hope this helps.
    Reward if helpful.
    Regards,
    Sipra

  • Disallow sending External email

    Hi, how to configure Exchange 2013 to disallow certain users to send external email

    Hi,
    As what DareDevil57 mentioned above, we can create a transport rule to meet this requirement.
    Here is an article about transport rule for your reference.
    Transport Rules:
    http://social.technet.microsoft.com/Forums/en-US/dedce6eb-f4b9-42be-b732-dba691b6c284/disallow-sending-external-email?forum=exchangesvradmin
    Hope this helps.
    Best regards,
    Belinda
    Belinda Ma
    TechNet Community Support

  • Convert ABAP Report to HTML & Send External Email Attachment

    Hi,
    I have a requirement described as below. A report is scheduled to run in the background creates a spool, to be converted to HTML format and send to Third Parties (External Email ID's) via Email. Please let me know whether the requirement is not clear. Can you please suggest me a suitable SAP Solution for this requirement?
    Thanks,
    Kannan.SA

    Hi,
    See below simple report to convert the internal table data to a HTML format data and stores in a internal table and then pass that internal table as an attachment to the external email using function module SO_NEW_DOCUMENT_ATT_SEND_API1.
    You need for create a spool also.
    REPORT  Z_HTML                                                      .
    include <icon>.
    types: begin of msg,
             type      like icon-id,
             text(140) type c,
           end of msg.
    constants: gc_marked type c value 'X',
               gc_ok     like icon-id  value '@5B@'.
    data:
       gt_msg         type standard table of msg,
       gs_msg         like line of  gt_msg,
       gv_msg(138)    type c,
    *-- html
       html_container type ref to cl_gui_custom_container,
       html_control   type ref to cl_gui_html_viewer,
       my_row_header like w3head   occurs 10 with header line,
       my_fields     like w3fields occurs 10 with header line,
       my_header     like w3head,
       my_html       type standard table of w3html  ,
       ok_code       like sy-ucomm.
      Start of Selection                                              *
    start-of-selection.
        clear gv_msg.
        gv_msg = 'MESSAGES for HTML'.
        do 3 times.
          perform message using  gc_ok gv_msg .
        enddo.
      End of   Selection                                              *
    end-of-selection.
        set screen 0100.
    *&      Form  message
    form message using    p_type
                          p_text.
      clear gs_msg.
      gs_msg-type  = p_type.
      gs_msg-text  = p_text.
      append gs_msg to gt_msg.
    endform.                    " MESSAGE
    *&      Module  STATUS_0100  OUTPUT
    module status_0100 output.
      perform convert_itab_html.
      set titlebar '100' .
      set pf-status 'MAIN100'.
      create object html_container
          exporting
              container_name = 'CONTAINER'.
      create object html_control
           exporting
                parent    = html_container
                saphtmlp  = gc_marked      .
      data: assigned_url type url.
      call method html_control->load_data
    EXPORTING
       URL                  = url
       TYPE                 = 'text'
       SUBTYPE              = 'html'
       SIZE                 = 0
       ENCODING             =
       CHARSET              =
        importing
          assigned_url         = assigned_url
        changing
          data_table           = my_html
    EXCEPTIONS
       DP_INVALID_PARAMETER = 1
       DP_ERROR_GENERAL     = 2
       CNTL_ERROR           = 3
       others               = 4
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
      call method html_control->show_url
        exporting
          url                    = assigned_url
       FRAME                  =
       IN_PLACE               = ' X'
    EXCEPTIONS
       CNTL_ERROR             = 1
       CNHT_ERROR_NOT_ALLOWED = 2
       CNHT_ERROR_PARAMETER   = 3
       DP_ERROR_GENERAL       = 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.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  exit  INPUT
    module exit input.
      leave program.
    endmodule.                 " exit  INPUT
    *&      Module  user_command_0100  INPUT
          text
    module user_command_0100 input.
      case ok_code.
        when 'EXIT' or 'BACK'.
          leave program.
        when others.
          call method cl_gui_cfw=>dispatch.
      endcase.
    endmodule.                 " user_command_0100  INPUT
    *&      Form  convert_itab_html
    form convert_itab_html.
      data: lv_tabix like sy-tabix.
    *-- table header
      call function 'WWW_ITAB_TO_HTML_HEADERS'
        exporting
          field_nr = 1
          text     = 'Type'
          fgcolor  = 'navy'
          bgcolor  = 'red'
          font     = 'Arial'
        tables
          header   = my_row_header.
      call function 'WWW_ITAB_TO_HTML_HEADERS'
        exporting
          field_nr = 2
          text     = 'Message'
          fgcolor  = 'navy'
          bgcolor  = 'red'
          font     = 'Arial'
        tables
          header   = my_row_header.
    *-- table rows
      clear lv_tabix.
      loop at gt_msg into gs_msg.
        lv_tabix = sy-tabix.
            call function 'WWW_ITAB_TO_HTML_LAYOUT'
              exporting
                field_nr = 1
                line_nr  = lv_tabix
                icon     = gc_marked
              tables
                fields   = my_fields.
            call function 'WWW_ITAB_TO_HTML_LAYOUT'
              exporting
                field_nr = 2
                line_nr  = lv_tabix
                fgcolor  = 'red'
                bgcolor  = 'black'
                font     = 'Arial'
                size     = '2'
              tables
                fields   = my_fields.
      endloop.
    *-- header
      move 'Messages during program run' to my_header-text.
      move 'Arial'                       to my_header-font.
      move '2'                           to my_header-size.
      move 'Centered'                    to my_header-just.
      move 'red'                         to my_header-bg_color.
      move 'blue'                        to my_header-fg_color.
      refresh my_html.
      call function 'WWW_ITAB_TO_HTML'
       exporting
         table_header = my_header
       all_fields   = ' '
        tables
          html         = my_html
          fields       = my_fields
          row_header   = my_row_header
          itable       = gt_msg.
    endform.                    "convert_itab_html

  • How to send external email of a Purchase Order

    Hello,
    I have to send an external email (pdf attachment) of a Purchase Order.
    I use the standard sap program: /SMB40/FM06P and the smartform: /SMB40/MMPO_L.
    Within transaction NACE I used the following entries:
    Medium: 5 (External Send), Program: /SMB40/FM06P, Form routine: ENTRY NEU and Smartform: /SMB40/MMPO_L.
    After running transaction ME22n (messages: External Send) I got the following error-messages in processing log:
    - Please maintain an output device in your user master data.
    - Archiving format not equal to PDF.
    Please, can someone help me to solve this problem.
    Regards,
    Rajesh

    hi
    U need to write the code to convert the smartform to PDF using FM Convert_otf and also for sending mail
    The standard program has to be copied to Z and write ur code..to perform u requirements
    Check the below links
    SO_NEW_DOCUMENT_ATT_SEND_API1
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8cd6adbb-0301-0010-39ba-938c601d5db9
    Email Invoices to customer as a PDF attachment
    surya

  • Send External email only when PR's created

    Hi
    i need help in the following workflow scenario
    I need to send the external Email (outlook,gmail etc) from workflow on a daily basis..
    The body of email should contain the purchase requisitions created for a particular day
    if there are no PR's Created ..we should not send an email.
    Approve and Reject are not necessary for now...
    Please let me know how to approach this scenario..
    Thanks
    Madhusudhan

    Hi Madhu,
    You need to identify the BO to be used for PR (for Overall PR its BUS2105, Item wise PR its BUS2009).
    Check if you can use the existing events else, create a Z-BO, delegate it to std BO and add an event CREATED.
    Trigger this event when ever the PR is created.
    Use this event as the triggering event of the workflow.
    In the workflow add a send mail step to send mail to the desired user email address.
    You can also use Action profiles to achieve the same.
    Hope this helps!
    Regards,
    Saumya

  • UCCX Send eMail unable to send external emails

    Hi,
    I created a script where it asks the user to record a prompt and then it sends that prompt as an attachment via email. I am able to get it to send the email internally on our domain, however unable to send the email externally. I did a Reactive Script debug and there are no error messages. I tried searching through the MIVR logs but cannot find anything, or don't know what to look for. Any insight? We are running UCCX 8.5 Premium. Are there any tests I can do through the CLI to test port connectivity to Exchange? It's very odd that it's able to send the email internally.
    Thank you.

    If its getting to Exchange and you are able to send emails internally but not externally, i think its an exchange issue. Maybe its because the From address is not assigned in Exchange and Exchange or your spam filter might not allow to send emails out.

  • Sending external email from forms

    Hello.
    I want to send an email using a form and a report. The report is the attachment of the email. I run the report from form using this command
    v_rep := RUN_REPORT_OBJECT(repid);
    If i send the mail to an internal address, works properly. If i want to send the email to an external address i have this error:
    FRM-41214
    Error when running report ORA - 0000: normal, successful completion
    I made a check with telnet on my computer and i managed to send an mail to an external address.
    Anyone has any idea?
    Thanks.

    I looked at the logs on the SMTP server, the extern mail doesn't even reach the SMTP server queue.
    I enabled the trace for the report server and I get this error:
    [2008/6/6 0:52:18:703] Exception 50152 (): Error while sending mail - Sending failed;
    nested exception is:
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    javax.mail.SendFailedException: 550 5.7.1 Unable to relay for [email protected]
    oracle.reports.RWException: IDL:oracle/reports/RWException:1.0
    at oracle.reports.utility.Utility.newRWException(Utility.java:756)
    at oracle.reports.server.MailService.send(MailService.java:492)
    at oracle.reports.server.DesMail.sendFile(DesMail.java:186)
    at oracle.reports.server.Destination.send(Destination.java:489)
    at oracle.reports.server.JobObject.distribute(JobObject.java:1582)
    at oracle.reports.server.JobManager.updateJobStatus(JobManager.java:2231)
    at oracle.reports.server.EngineCommImpl.updateEngineJobStatus(EngineCommImpl.java:134)
    at oracle.reports.server._EngineCommImplBase._invoke(_EngineCommImplBase.java:94)
    at com.sun.corba.se.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:353)
    at com.sun.corba.se.internal.iiop.ORB.process(ORB.java:280)
    at com.sun.corba.se.internal.iiop.RequestProcessor.process(RequestProcessor.java:81)
    at com.sun.corba.se.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:106)
    Thanks

  • Send External Email

    Hi All
    My requirement is to send an email (Lets say, to my gmail ID).
    I have tried FMs SO_DOCUMENT_SEND_API1 and SO_OBJECT_SEND.
    In FM SO_DOCUMENT_SEND_API1 , email is only reaching till SCOT/SOST and not moving further. The only way that the mail can be sent is through the Standard Report rsconn01. Again when I use SUBMIT RSCONN01, all the mails pending in SOST are released and sent to the respective ids. What I want here is only the email which has been sent from my ID should be released from sapconnect.
    In FM SO_OBJECT_SEND, no error is being reported (sy-subrc EQ 0) but there is no trace of this email, anywhere.
    This is the sample of data i m passing to FM so_object_send
        DATA: hd_change LIKE sood1.
        DATA: receivers LIKE soos1 OCCURS 0 WITH HEADER LINE.
        DATA: emailbody LIKE soli OCCURS 0 WITH HEADER LINE.
        hd_change-objla = 'EN'.
        hd_change-objdes = 'Errors'.
        hd_change-objsns = 'F'.
        receivers-recesc = 'U'.
        receivers-recextnam =  'Mygmailid'.
        receivers-sndart = 'INT'.
        APPEND receivers.
    Create the error message
          APPEND 'This is test message' TO emailbody.
          APPEND 'This is test message'  TO emailbody.
          APPEND 'This is test message'  TO emailbody.
          APPEND 'This is test message' TO emailbody.
          APPEND 'This is test message'  TO emailbody.
          APPEND 'This is test message' TO emailbody.
          APPEND 'This is test message'  TO emailbody.
        CALL FUNCTION 'SO_OBJECT_SEND'
          EXPORTING
            object_hd_change           = hd_change
            object_type                = 'RAW'
            outbox_flag                = 'X'
            owner                      = sy-uname
          TABLES
            objcont                    = emailbody[]
            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
            originator_not_exist       = 20
            x_error                    = 21
            OTHERS                     = 22.
    Can you kindly help me sending the email.

    Hello,
    At the end of teh program just give:
    SUBMIT RSCONN01 WITH MODE EQ 'INT' AND RETURN.
    This willl only send the emails i.e mode is internet users.
    Regards,
    Neeraj

  • Send external email when work item is triggered

    Hello,
    i have implemented the standard sap workflow for release of purchase requistions.
    I would like to introduce a functionality that for the approver with the high spending authorities e.g. the user which are rarely in SAP because it is the CxOs will receive automatically a notification via Lotus notes email system.
    What do I have to do in order:
    to create and send an email from SAP to Lotus Notes
    to only send an email to some approvers (I would like to avoid sending everybody an email, otherwise low level approvers get spammed with approval emails).
    Thank you very much for your support.

    Hello,
    If you want to just send an email notifying them of workitems, then depending on your version you would use RSWUWFML2 or Extended Notifications.
    If you want them to be able to action the PRs then I think that's possible from Lotus Notes, try searching this forum.
    regards
    Rick Bakker
    Hanabi Technology

  • Problem sending external emails

    Hello,
    we are trying to have our SAP system send mails to external customers and are having problems. The mails that we send to our internal users are working fine.
    we are on ECC6 and using a Microsoft exchange 2007 mail server. Our servers are outsourced.
    The things that we have done so far are:
    we have look at note 455140 and have that in place.
    we have a user set up in SU01 with the external address.
    we have sent our SAP IP address to the mail support team and they authenticated in  SMTP relay.
    we have configured SCOT and able to send emails internal users. *.mycompany.com
    we have checked the mail functions that can be used within ABAP code to see if there is a way to authenticate to the server with a user id and password.
    we can see that the emails are getting sent to the SMTP server but are being blocked at that point. our mail support team is stating that our problem is that we are not authenticating to the SMTP server. They are telling us that we have to sign in with a userid and password every time that we want to send a mail.
    please let us know if there is something else that we need to do in order to get this work.  if there is someone in here that is running ECC6 with a Microsoft exchange 2007 mail server that is successfully sending emails to external customers ( we have no issues with internal emails), can you please let us know what steps you have performed in order to get the process to work.
    Edited by: Timothy Hixson on Oct 24, 2011 8:43 PM

    Timothy Hixson wrote:
    If you have a Mail team just ask them to add the IP Address of your SAP Servers into the SMTP Relay Agent and that should fix your issue
    >
    > we have asked the mail team to do this and they have responded that they did. They are telling us that we have to authenicate to the mail server.
    I would suggest to discuss with your mail team that SAP does not support authentication mechanism in SMTP. So, install one relay agent between SAP system and mail server so that when mails are sent from SAP system to relay agent then relay agent will authenticate to your mail server and mail will be sent then.
    Thanks
    Sunny

Maybe you are looking for