Skip to Content
author's profile photo Former Member
Former Member

MAIL FROM SAP

Hi GURUS.

i am trying to send a mail from sap

output is coming well but mail not going

why??

TABLES: RS38M.

DATA : BEGIN OF I_MAIL_TEXT OCCURS 0,

FIELD(72) TYPE C,

END OF I_MAIL_TEXT.

DATA : V_TEXT(72) TYPE C.

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK MAIL WITH FRAME TITLE TEXT-014.

SELECTION-SCREEN BEGIN OF LINE.

  • Checkbox for sending Mail.

PARAMETERS: P_MAIL AS CHECKBOX DEFAULT 'X'.

SELECTION-SCREEN COMMENT (17) TEXT-001.

SELECTION-SCREEN COMMENT (7) TEXT-002.

SELECTION-SCREEN POSITION 33.

PARAMETERS: P_EMAIL(60) TYPE C LOWER CASE

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

PARAMETERS: SUBJECT(60) TYPE C DEFAULT

'Test mail from SAP by vasu = ZVSEND_MAIL'.

SELECTION-SCREEN SKIP 1.

PARAMETERS: P_PROG LIKE RS38M-PROGRAMM DEFAULT SY-REPID.

PARAMETERS: P_MFILE(60) TYPE C LOWER CASE DEFAULT

'E:\usr\sap\ESM\DVEBMGS00\data\vas1.txt'.

SELECTION-SCREEN END OF BLOCK MAIL.

************************************************************************

  • Sending a SAP mail to User

IF NOT P_MAIL IS INITIAL.

PERFORM POP_MAIL.

PERFORM MAILING.

ENDIF.

************************************************************************

&----


*& Form MAILING

&----


  • text

----


FORM MAILING.

*CALL FUNCTION 'RS_SEND_MAIL_FOR_SPOOLLIST'

  • EXPORTING

  • SPOOLNUMBER = SY-SPONO

  • MAILNAME = 'test'

  • MAILTITEL = 'test mail'

  • USER = P_UNAME "sy-uname

  • TABLES

  • TEXT = I_CHECK

  • EXCEPTIONS

  • ERROR = 1

  • OTHERS = 2.

  • *Local Data Declaration

    DATA : COMND(200) TYPE C.

    DATA : TAB(200) TYPE C OCCURS 100 WITH HEADER LINE.

    OPEN DATASET P_MFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

    IF SY-SUBRC NE 0.

    MESSAGE E004(ZP) WITH 'Unable to Open File : ' P_MFILE.

    ENDIF.

    LOOP AT I_MAIL_TEXT.

    TRANSFER I_MAIL_TEXT TO P_MFILE.

    ENDLOOP.

    CLOSE DATASET P_MFILE.

    *Logic for sending email

    TRANSLATE P_EMAIL TO LOWER CASE.

    • CONCATENATE 'cat' P_MFILE '| mail -s "' SUBJECT '"' P_EMAIL

    • INTO COMND SEPARATED BY SPACE.

    • Sending Mail with Attachment.

    • CONCATENATE 'uuencode' P_MFILE 'TEST.XLS'

    CONCATENATE 'uuencode' P_MFILE 'TEST.TXT'

    '| mail -s "' SUBJECT '"' P_EMAIL

    INTO COMND SEPARATED BY SPACE.

    CALL 'SYSTEM' ID 'COMMAND' FIELD COMND

    ID 'TAB' FIELD TAB-SYS.

    • ID 'TAB' FIELD RESULT[].

    DELETE DATASET P_MFILE.

    • write

    LOOP AT I_MAIL_TEXT.

    WRITE: /2 I_MAIL_TEXT-FIELD.

    ENDLOOP.

    CLEAR SY-TFILL.

    DESCRIBE TABLE TAB LINES SY-TFILL.

    WRITE: /2 SY-TFILL.

    ENDFORM. " MAILING

    &----


    *& Form POP_MAIL

    &----


    FORM POP_MAIL.

    READ REPORT P_PROG INTO I_MAIL_TEXT.

    CLEAR V_TEXT.

    INSERT V_TEXT INTO I_MAIL_TEXT INDEX 1.

    CLEAR V_TEXT.

    V_TEXT = ' : Cell: (410)258 2686'.

    INSERT V_TEXT INTO I_MAIL_TEXT INDEX 1.

    CLEAR V_TEXT.

    V_TEXT = ' : HOME: (973)439 7270'.

    INSERT V_TEXT INTO I_MAIL_TEXT INDEX 1.

    CLEAR V_TEXT.

    V_TEXT = 'Contact No: Work: (201)760 3964'.

    INSERT V_TEXT INTO I_MAIL_TEXT INDEX 1.

    CLEAR V_TEXT.

    V_TEXT = 'Created by srinivasu. Mail Id: '.

    INSERT V_TEXT INTO I_MAIL_TEXT INDEX 1.

    V_TEXT = 'This mail is triggered by SAP Program : ZVSEND_MAIL'.

    INSERT V_TEXT INTO I_MAIL_TEXT INDEX 1.

    CLEAR V_TEXT.

    ENDFORM.

    Regadrs.

    Sri

    Add a comment
    10|10000 characters needed characters exceeded

    Assigned Tags

    Related questions

    1 Answer

    • author's profile photo Former Member
      Former Member
      Posted on Jun 19, 2008 at 10:41 AM

      any body

      Add a comment
      10|10000 characters needed characters exceeded

    Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.