06-18-2008 3:49 AM
Hi
i want send mail to outlook. Following code is working fine. I am hard coded the mail address here. Instead of this i want to extract the mailid from Z1ychclientid table and sent mail to Z1ychclientid table mail address
i changed this in program. but it is going to dump. pls help me.
pls dont suggest any other FM
data declaration
data: maildata type sodocchgi1.
data: mailtxt type table of solisti1 with header line.
DATA : BEGIN OF MAILREC OCCURS 0,
EMAIL1(30),
EMAIL2(30),
EMAIL3(30),
EMAIL4(30),
EMAIL5(30),
EMAIL6(30),
EMAIL7(30),
EMAIL8(30),
EMAIL9(30),
EMAIL10(30),
end OF MAILREC.
*data: mailrec type table of somlrec90 with header line.
Code
form SEND_MAIL .
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'DDL Reloaded for Approvel Number'.
CONCATENATE maildata-obj_descr p_appno INTO maildata-obj_descr.
maildata-obj_langu = sy-langu.
mailtxt-line = 'Please Note above request has been Completed'.
append mailtxt.
select email1 email2 email3 email4 email5
email6 email7 email8 email9 email10
from z1ychclientid into table mailrec
where werks = p_werks.
if mailrec[] is not initial.
endif.
mailrec-receiver = 'name.company.com'. "i hadr coded the mail address here
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'RAW'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
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.
COMMIT WORK.
if sy-subrc = 0.
*write : 'mail sent'.
endif.
endform. " SEND_MAIL
06-18-2008 4:01 AM
Hi Kumar,
Your MAILREC internal table have to be like SOMLRECI1 structure.
You can't define your own structure for MAILREC else it will shortdump.
Hope it helps,
Victor.
06-18-2008 4:11 AM
Hi Victor
I change the program. Pls advise me changes or correct or not
data: maildata type sodocchgi1.
data: mailtxt type table of solisti1 with header line.
DATA : BEGIN OF MAILREC1 OCCURS 0,
EMAIL1(30),
EMAIL2(30),
EMAIL3(30),
EMAIL4(30),
EMAIL5(30),
EMAIL6(30),
EMAIL7(30),
EMAIL8(30),
EMAIL9(30),
EMAIL10(30),
end OF MAILREC1.
data: mailrec type table of somlrec90 with header line.
form SEND_MAIL .
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'DDL Reloaded for Approvel Number'.
CONCATENATE maildata-obj_descr p_appno INTO maildata-obj_descr.
maildata-obj_langu = sy-langu.
mailtxt-line = 'Please Note above request has been Completed'.
append mailtxt.
select email1 email2 email3 email4 email5
email6 email7 email8 email9 email10
from z1ychclientid into table mailrec1
where werks = p_werks.
if mailrec1[] is not initial.
mailrec-receiver = mailrec1-email1. " Email1 is not moving to mailrec
append mailrec.
mailrec-receiver = mailrec1-email2.
append mailrec.
mailrec-receiver = mailrec1-email3.
append mailrec.
mailrec-receiver = mailrec1-email4.
append mailrec.
mailrec-receiver = mailrec1-email5.
append mailrec.
mailrec-receiver = mailrec1-email6.
append mailrec.
mailrec-receiver = mailrec1-email7.
append mailrec.
mailrec-receiver = mailrec1-email8.
append mailrec.
mailrec-receiver = mailrec1-email9.
append mailrec.
mailrec-receiver = mailrec1-email10.
append mailrec.
mailrec-rec_type = 'U'.
append mailrec.
endif.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'RAW'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
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.
COMMIT WORK.
if sy-subrc = 0.
*write : 'mail sent'.
endif.
endform. " SEND_MAIL
06-18-2008 4:16 AM
Hi Kumar,
I think this should be the correct way:
mailrec-rec_type = 'U'.
mailrec-receiver = mailrec1-email1.
append mailrec.
mailrec-receiver = mailrec1-email2.
append mailrec.
mailrec-receiver = mailrec1-email3.
append mailrec.
mailrec-receiver = mailrec1-email4.
append mailrec.
mailrec-receiver = mailrec1-email5.
append mailrec.
mailrec-receiver = mailrec1-email6.
append mailrec.
mailrec-receiver = mailrec1-email7.
append mailrec.
mailrec-receiver = mailrec1-email8.
append mailrec.
mailrec-receiver = mailrec1-email9.
append mailrec.
mailrec-receiver = mailrec1-email10.
append mailrec.
You try it first.
Hope it is correct
Victor.
06-18-2008 5:06 AM