‎2006 Sep 07 1:30 PM
HI all,
I am checking the expiratio date of the user id and if it is very nearer then I need tto send them email with some message from my program . So can you please give me function module or <b>code</b> how I can send email to employees
thanks
‎2006 Sep 07 1:32 PM
Hi,
You can use function module SO_NEW_DOCUMENT_ATT_SEND_API1 for sending email with attachment. You can view the Function module documentation which have details regarding implementation with sample code.
Hope this helps.
Message was edited by: Imtiaz Ahmed
‎2006 Sep 07 1:33 PM
Hi,
Here is an example code for you.
REPORT zramki_submit_self .
PARAMETERS:
p_date LIKE sy-datum DEFAULT sy-datum,
p_submit NO-DISPLAY.
IF p_submit IS INITIAL.
SUBMIT (sy-repid) WITH p_date = p_date
WITH p_submit = 'X'
EXPORTING LIST TO MEMORY AND RETURN.
Process the list here and send the mail
ELSE.
Generate the report here.
do 5 times.
WRITE: /1 sy-index, sy-datum.
enddo.
EXIT.
ENDIF.
Regards,
Ram
Pls reward points if helpful
‎2006 Sep 07 1:34 PM
http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
if you want to send email to the SAP user then
receivers-REC_TYP = 'B'.
Or if you want to send it to an internet mail id,
then REC_TYP = 'U'.
you can use the same function module to send for either of them.
regards
srikanth
Message was edited by: Srikanth Kidambi
‎2006 Sep 07 1:40 PM
hi ,
kindly chekc the code below.
&----
*& Form f_send_mail
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_send_mail .
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.
*store the vendor name, vendor email id , employee name and employee
*email id in the internal table int_crb
Creation of the document to be sent
CLEAR doc_chng.
REFRESH objpack.
REFRESH objhead.
REFRESH reclist.
REFRESH objtxt.
File Name
doc_chng-obj_name = 'SHIPMENT'.
Mail Subject
CONCATENATE 'Shipment Document No.' int_crb_mail-shipdocnum
'Cleared.'
INTO doc_chng-obj_descr SEPARATED BY ' '.
Mail Contents
objtxt-line = 'Hi,'.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
CONCATENATE 'Shipment Document Number ' int_crb_mail-shipdocnum
' cleared for move.' INTO objtxt-line SEPARATED BY ' '.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
CLEAR objtxt.
objtxt-line = 'Regards '.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
objtxt-line = 'SAP '.
APPEND objtxt.
CLEAR objtxt.
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.
Completing the recipient list
target recipent
CLEAR reclist.
reclist-receiver = int_crb_mail-empperid. "employee email ID
"wf_empperid.
reclist-express = 'X'.
reclist-rec_type = 'U'.
APPEND reclist.
copy recipents
CLEAR reclist.
reclist-receiver = int_crb_mail-smtp_addr."vendor email id
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.
hope this wiil help u.
for any clarifivation pls mail
kindly reward points if this helped u.
regards,
anversha.
anversha.shahul@wipro.com
‎2006 Sep 07 2:03 PM
THe code below may help u.
FORM send_mail USING p_y16m_rcp_par STRUCTURE y16m_rcp_par.
Have a subject for the mail
g_s_document_data-obj_name = text-t02.
g_s_document_data-obj_descr = text-t03.
Fill receiver information
g_s_receivers-rec_type = p_y16m_rcp_par-rec_type.
g_s_receivers-rec_id = p_y16m_rcp_par-rec_id.
g_s_receivers-express = 'X'.
APPEND g_s_receivers TO g_t_receivers.
Call function to send mail
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = g_s_document_data
document_type = 'RAW'
PUT_IN_OUTBOX = ' '
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
OBJECT_HEADER =
object_content = g_t_object_content
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = g_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
.
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. " SEND_MAIL
Regards