Sending mails from your application

Hello Friends,

Most of the times will get the requirement on this.
There are some predefined function modules to send the mail from SAP application.
Here i am explaining about the Function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
In this Function Module we need to pass some parameters,


CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = Z_DOC_DATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'

TABLES
PACKING_LIST = Z_TAB_PACK
* OBJECT_HEADER =
* CONTENTS_BIN =
CONTENTS_TXT = Z_TAB_TXT
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = Z_TAB_REC
* 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.


Here
DOCUMENT_DATA is a structure ,

Z_DOC_DATA-DOC_SIZE = ( Z_TAB_LINES - 1 ) * 255 + STRLEN( Z_TAB_TXT ).
Z_DOC_DATA-OBJ_LANGU = SY-LANGU.
Z_DOC_DATA-OBJ_NAME = 'XYZ'.
Z_DOC_DATA-OBJ_DESCR = Z_V_SUB. " Subject line
Z_DOC_DATA-SENSITIVTY = 'F'.

There is a table called PACKING_LIST,

CLEAR : Z_TAB_PACK.
REFRESH : Z_TAB_PACK.
Z_TAB_PACK-TRANSF_BIN = SPACE.
Z_TAB_PACK-HEAD_START = 1.
Z_TAB_PACK-HEAD_NUM = 0.
Z_TAB_PACK-BODY_START = 1.
Z_TAB_PACK-DOC_TYPE = 'RAW'.
DESCRIBE TABLE Z_TAB_TXT LINES Z_TAB_PACK-BODY_NUM.
APPEND Z_TAB_PACK.
Then Recivers are :

* Add the recipients email address
CLEAR : Z_TAB_REC.
REFRESH : Z_TAB_REC.
Z_TAB_REC-RECEIVER = Z_V_EMAIL.
Z_TAB_REC-REC_TYPE = 'U'.
Z_TAB_REC-COM_TYPE = 'INT'.
Z_TAB_REC-NOTIF_DEL = 'X'.
Z_TAB_REC-NOTIF_NDEL = 'X'.
APPEND Z_TAB_REC.
You can send a mail to n number of recievers.
If you passed these parameters you will get the mail.
If you are not getting the mail, just run the BASIS transaction SCOT.

Then, Immediatly you will get the mail in to your mail box.


Thanks to all.

Please don't forget drop comments, Then only i can post more reliable