HTML formatında Eposta Gönderme
SO_NEW_DOCUMENT_SEND_API1 ile HTML formatında eposta gönderme örneği
Structure ve type lar en alttadır
*&---------------------------------------------------------------------*
*& Form SEND_MAIL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PRM_MUSTERI text
* -->PTR_ITEMS text
*----------------------------------------------------------------------*
form send_mail_musteri using prm_musteri type ztr_mlkbl_tolrns
prt_items type tty_mail_items
changing chn_ok type xfeld.
* Data Declarations
data: ls_log type ztr_mlkbl_log_ep.
data: ls_mailsubject type sodocchgi1.
data: lt_mailrecipients type standard table of somlrec90 .
data: lt_mailtxt type standard table of soli .
data: ls_mailrecipient type somlrec90 .
data: ls_mailtxt type soli .
data: ls_item type ty_mail_items .
data: lv_format_date type char20.
data: lv_format_time type char20.
data: lv_format_lenum type char20.
clear chn_ok.
* Subject.
ls_mailsubject-obj_name = `Mal Kabul Gecikmesi ` .
ls_mailsubject-obj_langu = `TR`.
ls_mailsubject-obj_descr = `Mal kabulu gerçekleşmeyen siparişler ` .
ls_mailrecipient-rec_type = `U`.
ls_mailrecipient-receiver = prm_musteri-eposta.
append ls_mailrecipient to lt_mailrecipients .
* Mail Contents
clear ls_mailtxt.
concatenate `
Sayın`
prm_musteri-adsoyad `,` c_br into ls_mailtxt-line separated by space.append ls_mailtxt to lt_mailtxt.
ls_mailtxt-line = `Aşağıdaki siparişlerin mal kabulu gerçekleşmemiştir : ` .
append ls_mailtxt to lt_mailtxt.
ls_mailtxt-line = c_br. append ls_mailtxt to lt_mailtxt.
ls_mailtxt-line = c_br. append ls_mailtxt to lt_mailtxt.
ls_mailtxt-line = c_br. append ls_mailtxt to lt_mailtxt.
ls_mailtxt-line = ``
ls_mailtxt-line = `` .append ls_mailtxt to lt_mailtxt.
concatenate `` c_spc_html `Sipariş` c_spc_html `` into ls_mailtxt-line .append ls_mailtxt to lt_mailtxt.
concatenate `` c_spc_html `Teslimat` c_spc_html `` into ls_mailtxt-line .append ls_mailtxt to lt_mailtxt.
concatenate `` c_spc_html `Mal Çıkış Tarihi` c_spc_html `` into ls_mailtxt-line .append ls_mailtxt to lt_mailtxt.
concatenate `` c_spc_html `Mal Çıkış Saati` c_spc_html `` into ls_mailtxt-line .append ls_mailtxt to lt_mailtxt.
ls_mailtxt-line = `` .append ls_mailtxt to lt_mailtxt.
loop at prt_items into ls_item where kunnr = prm_musteri-kunnr.
write ls_item-plt_datum to lv_format_date .
write ls_item-plt_uzeit to lv_format_time .
* write ls_item-lenum to lv_format_lenum no-gap no-zero no-sign .
ls_mailtxt-line = `` .append ls_mailtxt to lt_mailtxt.
concatenate `` c_spc_html ls_item-vbeln c_spc_html `` into ls_mailtxt-line .append ls_mailtxt to lt_mailtxt.
concatenate `` c_spc_html ls_item-vbeln_t c_spc_html `` into ls_mailtxt-line .append ls_mailtxt to lt_mailtxt.
concatenate `` c_spc_html lv_format_date c_spc_html `` into ls_mailtxt-line .append ls_mailtxt to lt_mailtxt.
concatenate `` c_spc_html lv_format_time c_spc_html `` into ls_mailtxt-line .append ls_mailtxt to lt_mailtxt.
ls_mailtxt-line = `` .append ls_mailtxt to lt_mailtxt.
append ls_mailtxt to lt_mailtxt.
endloop.
ls_mailtxt-line = `` . .append ls_mailtxt to lt_mailtxt.
ls_mailtxt-line = c_br. append ls_mailtxt to lt_mailtxt.
append initial line to lt_mailtxt.
ls_mailtxt-line = `
Bilginize,
`.append ls_mailtxt to lt_mailtxt.
* Send Mail
call function `SO_NEW_DOCUMENT_SEND_API1`
exporting
document_data = ls_mailsubject
document_type = `HTM`
commit_work = `X`
tables
object_content = lt_mailtxt
receivers = lt_mailrecipients
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 eq 0.
ls_log-kunnr = prm_musteri-kunnr.
ls_log-tarih = sy-datum..
modify ztr_mlkbl_log_ep from ls_log.
commit work and wait .
chn_ok = `X`.
* Push mail out from SAP outbox
* SUBMIT RSCONN01 WITH MODE = `INT` AND RETURN.
endif.
endform. " SEND_MAIL
ZTR_MLKBL_TOLRNS tablo
mandt Mandt
KUNNR KUNNR
TOLERANS ZTR_E_YOL_SURESI_TOLERANS
ADSOYAD ZTR_E_ADSOYAD
EPOSTA AD_SMTPADR
TYPES: begin of ty_mail_items,
kunnr type kunnr,
vbeln type vbeln,
vbeln_t type vbeln,
lenum type lenum,
PLT_DATUM type ZTR_E_MAL_CIKIS_TARIHI,
PLT_UZEIT type ZTR_E_MAL_CIKIS_SAATI,
end of ty_mail_items.
types: tty_mail_items type sorted table of ty_mail_items with unique key kunnr vbeln lenum.
types: tty_mlkbl_tolrns type sorted table of ztr_mlkbl_tolrns with unique key kunnr.
constants c_br type char5 value `</br>`.
constants c_spc_html type char6 value ` `.