‎2005 Oct 25 6:26 AM
Hi All,
I am fetching the sender's email id dynamically from HR database and then trying to use it while sending email via FM SO_DOCUMENT_SEND_API1. But the email does not go. The FM is erroring out with return code 6.
If I maintain email id in the user profile (Tcode SU01) and then simply pass sy-uname instead of complete email address in parameter - sender_address then it is working fine.
Is it not possible to explicitly send 'From email id' or 'Sender-address' parameter when sending mails using FM SO_DOCUMENT_SEND_API1 like for example user@sap.com.
The experts please solve my problem...
Thanks & regards,
Rashmi
‎2005 Oct 25 6:54 AM
I dont think its possible with SO_DOCUMENT_SEND_API1 but I heard it is possible with SO_OBJECT_SEND.
Cheers.
‎2005 Oct 25 6:54 AM
I dont think its possible with SO_DOCUMENT_SEND_API1 but I heard it is possible with SO_OBJECT_SEND.
Cheers.
‎2005 Oct 25 7:04 AM
Thanx.
But using SO_OBJECT_SEND can I send PDF attachments also?
‎2005 Oct 25 7:08 AM
Yes you can as SO_DOCUMENT_SEND_API1 calls SO_OBJECT_SEND internally. Check the code in SO_DOCUMENT_SEND_API1.
Cheers
( Dont forget to reward if answers were helpful )
‎2005 Oct 26 2:24 AM
Thanks Sanjay.
You gave the info that I needed. I have used SO_OBJECT_SEND FM that allows to override sender's email id. I think I have given rating to you. Check n let me know if I have not done so.
Thanx for the others too but I wanted info about 'Sender's email id' and not 'receiver's email id'.
Regards,
Rashmi S
Message was edited by: Rashmi Sanathkumariah
‎2005 Oct 25 2:38 PM
Hi,
The FM for sending the attachment is
SO_NEW_DOCUMENT_ATT_SEND_API1 There is complete coding part in the FM Documentation. In case you are not using SO_OBJECT_SEND. So you can very well use this FM instead of SO_NEW_DOCUMENT_SEND_API1.
You can refer to the FM Documentation, there is complete coding for it.
Hope it helps you a lot.
Cheers,
Sampath
‎2005 Oct 25 2:48 PM
With FM SO_DOCUMENT_SEND_API1
you have to set following params to use an email-adress
receiver-receiver = email-adress.
receiver-rec_type = 'U'.
receiver-com_type = 'INT'.
Regards,
Dirk.
‎2005 Oct 25 2:50 PM
In this object i was able to send the mail. just check the type of reciever.
DATA: objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objhex like SOLIX occurs 0 with header line,
reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1,
v_tab_lines1 LIKE sy-tabix ,
v_temp type sy-tabix , "
v_doc_hdr type sy-tabix ,
v_tab_lines LIKE sy-tabix .
DATA : v_up TYPE i,
v_nup TYPE i.
IF cb_nonup EQ c_x.
READ TABLE i_get_latest WITH KEY upstream = space.
IF sy-subrc EQ 0.
v_nup = 1.
ENDIF.
ENDIF.
IF cb_upstm EQ c_x.
READ TABLE i_get_latest WITH KEY upstream = c_x.
IF sy-subrc EQ 0.
v_up = 1.
ENDIF.
ENDIF.
Setting up File Name & Mail Subject
doc_chng-obj_name = 'Attachment'(067). " File Name
IF v_up EQ 1 AND
v_nup EQ 1.
Subject
doc_chng-obj_descr = 'The list of Upstream / Non-Upstream'(066).
objtxt = 'Upstream/Non-Upstream files are attached'(065). " Body
ELSEIF v_up EQ 1.
Subject
doc_chng-obj_descr = 'The list of Upstream'(064).
objtxt = 'Upstream file is attached'(063). " Body
ELSEIF v_nup EQ 1.
Subject
doc_chng-obj_descr = 'The list of Non-Upstream'(062).
objtxt = 'Non-Upstream file is attached'(061). " Body
ENDIF.
data : v_del type x value '0A',
v_tab type x value 9 . "
Appending the body of the Mail
concatenate objtxt v_del into objtxt.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES v_doc_hdr.
READ TABLE objtxt INDEX v_doc_hdr.
doc_chng-doc_size = ( v_tab_lines - 1 ) * 480 + STRLEN( objtxt ).
doc_chng-doc_size = ( v_doc_hdr - 1 ) * 255 + STRLEN( objtxt ).
Creation of the entry for the Mail Contents
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = v_doc_hdr.
objpack-doc_type = 'RAW'.
APPEND objpack.
v_temp = 1. "
if cb_nonup eq c_x.
Creation of the Non-Upstream Xcel document as attachment
CLEAR objbin.
LOOP AT i_get_latest WHERE upstream EQ space.
objbin = i_get_latest .
concatenate objbin v_del into objbin.
APPEND objbin.
objtxt = i_get_latest.
concatenate objtxt v_del v_del into objtxt.
concatenate i_get_latest-massn+0(6)
v_tab
i_get_latest-massg+0(30)
v_tab
i_get_latest-aedtm
v_tab
i_get_latest-begda
v_tab
i_get_latest-pernr
v_tab
i_get_latest-nachn+0(12)
v_tab
i_get_latest-vorna+0(12)
v_tab
i_get_latest-midnm
v_tab
i_get_latest-ptext+0(20)
v_tab
i_get_latest-orgeh+0(8)
v_tab
i_get_latest-orgtx+0(25)
v_tab
i_get_latest-name1+0(30)
into objtxt.
append objtxt.
clear objtxt.
concatenate i_get_latest-bukrs+0(4)
v_tab
i_get_latest-kostl+0(10)
v_tab
i_get_latest-ltext+0(25)
v_tab
i_get_latest-ort01+0(15)
v_tab
i_get_latest-state+0(10)
v_tab
i_get_latest-func_org
v_tab
i_get_latest-fun_dept
v_tab
i_get_latest-chief_name
v_tab
i_get_latest-ess_role
v_tab
i_get_latest-email_id
into objtxt.
shift objtxt by 2 places right.
append objtxt.
Appending an empty line to demarcate records in attachment file
clear objtxt.
append objtxt.
ENDLOOP.
Creation of the entry for the Non-Upstream attachment
objhead = 'Non-Upstream.xls'(060). " Attachment Name
APPEND objhead.
clear objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 2.
objpack-body_num = v_tab_lines - v_doc_hdr.
objpack-doc_type = 'XLS'. "
objpack-doc_type = 'TXT'. "
objpack-obj_name = 'Non Upstream'(059).
objpack-obj_descr = 'Non Upstream'(059).
objpack-doc_size = v_tab_lines * 480. "
objpack-doc_size = ( v_tab_lines - v_doc_hdr ) * 255. "
APPEND objpack.
endif.
if cb_upstm eq c_x.
Creation of the Upstream Xcel document as attachment
CLEAR objbin.
LOOP AT i_get_latest WHERE upstream EQ c_x.
objbin = i_get_latest .
concatenate objbin v_del into objbin.
APPEND objbin .
objtxt = i_get_latest.
concatenate objtxt v_del v_del into objtxt.
append objtxt.
concatenate i_get_latest-massn+0(6)
v_tab
i_get_latest-massg+0(30)
v_tab
i_get_latest-aedtm
v_tab
i_get_latest-begda
v_tab
i_get_latest-pernr
v_tab
i_get_latest-nachn+0(12)
v_tab
i_get_latest-vorna+0(12)
v_tab
i_get_latest-midnm
v_tab
i_get_latest-ptext+0(20)
v_tab
i_get_latest-orgeh+0(8)
v_tab
i_get_latest-orgtx+0(25)
v_tab
i_get_latest-name1+0(30)
into objtxt.
append objtxt.
clear objtxt.
concatenate i_get_latest-bukrs+0(4)
v_tab
i_get_latest-kostl+0(10)
v_tab
i_get_latest-ltext+0(25)
v_tab
i_get_latest-ort01+0(15)
v_tab
i_get_latest-state+0(10)
v_tab
i_get_latest-func_org
v_tab
i_get_latest-fun_dept
v_tab
i_get_latest-chief_name
v_tab
i_get_latest-ess_role
v_tab
i_get_latest-email_id
into objtxt.
shift objtxt by 2 places right.
append objtxt.
Appending an empty line to demarcate records in attachment file
clear objtxt.
append objtxt.
ENDLOOP.
DESCRIBE TABLE objbin LINES v_tab_lines1. "
DESCRIBE TABLE objtxt LINES v_tab_lines1. "
objhead = 'Upstream.xls'(070). " Attachment Name
APPEND objhead.
if cb_nonup eq c_x.
v_temp = v_tab_lines. "
v_tab_lines = v_tab_lines1 - v_tab_lines.
else.
v_tab_lines = v_tab_lines1.
endif.
Creation of the entry for the compressed attachment
objpack-transf_bin = 'X'. "
clear objpack-transf_bin. "
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1. "
objpack-body_start = v_temp + 1. "
objpack-body_num = v_tab_lines. "
objpack-body_num = v_tab_lines - 1.
objpack-doc_type = 'XLS'. "
objpack-doc_type = 'TXT'. "
objpack-obj_name = 'Upstream'(058).
objpack-obj_descr = 'Upstream'(058).
objpack-doc_size = v_tab_lines * 480. "
objpack-doc_size = ( v_tab_lines ) * 255. "
APPEND objpack.
endif.
Completing the recipient list
reclist-receiver = p_emlid.
reclist-rec_type = 'U'.
APPEND reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
MESSAGE i000 WITH 'Error in sending Email'(052) .
ELSE.
MESSAGE i000 WITH 'Message sent successfully !'(050).
ENDIF.
ENDFORM. " send_email