on 01-16-2007 1:46 PM
Hello,
I have created a smartform on SAP 4.6C and have managed to send mail to a single SAP user using the standard macros as follows:
swc_set_element container 'AddressString'
sy-uname.
swc_set_element container 'TypeId' 'B'. "SAP Username
swc_call_method recipient 'CreateAddress' container.
However, I have not found any documentation on how to send mails to a list of recipients. Can anyone help me on that? Thanks a lot.
Tien
Hi ,
call the following function module in a loop and pass the values in the reciever list table with the no. of email ids and check the output .hope it works
Creating the entry for the compressed document
CLEAR gs_objpack-transf_bin.
gs_objpack-head_start = 1.
gs_objpack-head_num = 0.
gs_objpack-body_start = 1.
gs_objpack-body_num = gv_tab_lines.
gs_objpack-doc_type = 'RAW'.
APPEND gs_objpack TO gt_objpack.
Entering names in the distribution list
IF p_plist IS NOT INITIAL.
gs_reclist-receiver = p_plist.
gs_reclist-rec_type = gc_c.
APPEND gs_reclist TO gt_reclist.
CLEAR gs_reclist.
ENDIF.
Populating the reciever list
gs_reclist-receiver = p_plist.
gs_reclist-rec_type = gc_u.
APPEND gs_reclist TO gt_reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gs_doc_chng
put_in_outbox = gc_x
commit_work = gc_x
TABLES
packing_list = gt_objpack
object_header = gt_objhead
contents_bin = gt_objbin
contents_txt = gt_objtxt
receivers = gt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
CASE sy-subrc.
WHEN 0.
WRITE: 'eMail sent successfully'(005).
WHEN OTHERS.
WRITE: / 'eMail could not be sent'(008).
ENDCASE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Durgaprasad,
Thank you for your quick reply.
Actually I would like to use the standard mail function included in smartforms instead of using the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'. Therefore I am hoping to find a way to send mails to a list of recipients using the macros provided for mailing smartforms as follows:
...
sender
swc_create_object sender 'RECIPIENT' space.
swc_clear_container container.
swc_set_element container 'AddressString'
'sender@test.com'.
swc_set_element container 'TypeId' 'U'.
swc_call_method sender 'FindAddress' container.
swc_object_to_persistent sender sender_id.
recipient(s)
swc_create_object recipient 'RECIPIENT' space.
swc_clear_container container.
swc_set_element container 'AddressString' 'recipient@test.com'.
swc_set_element container 'TypeId' 'U'.
swc_call_method recipient 'CreateAddress' container.
swc_clear_container container.
swc_set_element container 'SendExpress' 'X'.
swc_call_method recipient 'SetExpress' container.
swc_clear_container container.
refresh recipient_tab.
swc_call_method recipient 'Expand' container.
swc_get_table container 'ResultTable' recipient_tab.
loop at recipient_tab.
clear job_info.
SWC_OBJECT_TO_PERSISTENT recipient_tab recipient_id.
CALL FUNCTION fm_name
EXPORTING
CONTROL_PARAMETERS = control_parameters
MAIL_RECIPIENT = recipient_id
MAIL_SENDER = sender_id
OUTPUT_OPTIONS = output_options
USER_SETTINGS = ' '
IW_FORM = w_form
IMPORTING
JOB_OUTPUT_INFO = job_info
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
l_subrc = sy-subrc.
ENDIF.
endloop.
...
The above coding actually works for printing, faxing or mailing. However, I only manage to send to smartform to one recipient. I am wondering whether there is an elegant way to send the form to a list of recipients.
Of course if there is no "elegant" way, then I could loop around the list of recipients and create the containers and call the smarform function module for each recipient. This way I would create one separate mail for each recipient though.
Regards
Tien
hi,
in order to change that u have to alter ur print program and use condition value of nacha ...on the other side u have to configure the nace output type and make the scot settings.
for this use the following code.
&----
*& Form nacha_5
&----
Send the Form as an Email
----
-->P_FOUND Flag 'X' if sub routine is found
----
FORM nacha_5 USING write_out TYPE xfeld
CHANGING p_found TYPE xfeld.
DATA : lv_mail_id TYPE so_name,
lv_mail_tp TYPE so_escape VALUE 'U',
l_subrc TYPE sy-subrc.
p_found = 'X'.
Get the Mail ID from the Control Table
lv_mail_id = t_ctrl_app-recipient.
Create The Recipient Object
CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
EXPORTING
ip_mailaddr = lv_mail_id
ip_type_id = lv_mail_tp
IMPORTING
ep_recipient_id = w_recipient
EXCEPTIONS
invalid_recipient = 1
OTHERS = 2.
IF sy-subrc NE 0.
IF write_out = 'X'.
FORMAT COLOR 6.
WRITE AT /5 text-001.
ENDIF.
RAISE other.
ENDIF.
Create The Sender Object
CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
EXPORTING
ip_sender = sy-uname
IMPORTING
ep_sender_id = w_sender
EXCEPTIONS
invalid_sender = 1
OTHERS = 2.
IF sy-subrc NE 0.
IF write_out = 'X'.
FORMAT COLOR 6.
WRITE AT /5 text-002.
ENDIF.
RAISE other.
ENDIF.
Populate the Control Data & Title
w_sf_control-device = 'MAIL'.
w_sf_control-no_dialog = 'X'.
w_sf_control-langu = t_ctrl_app-spras.
***************************************************
Nacha = 2
Populate the Fax Number and the country.
Data : lv_fax_tp TYPE so_escape VALUE 'F',
lv_fax = t_ctrl_app-recipient.
lv_land1 = t_ctrl_app-country.
Create the Recipient Object
CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
EXPORTING
ip_country = lv_land1
ip_faxno = lv_fax
ip_type_id = lv_fax_tp
IMPORTING
ep_recipient_id = w_recipient
EXCEPTIONS
invalid_recipient = 1
OTHERS = 2.
IF sy-subrc NE 0.
IF write_out = 'X'.
FORMAT COLOR 6.
WRITE AT /5 text-004.
ENDIF.
RAISE other.
ENDIF.
Create The Sender Object
CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
EXPORTING
ip_sender = sy-uname
IMPORTING
ep_sender_id = w_sender
EXCEPTIONS
invalid_sender = 1
OTHERS = 2.
IF sy-subrc NE 0.
IF write_out = 'X'.
FORMAT COLOR 6.
WRITE AT /5 text-003.
ENDIF.
RAISE other.
ENDIF.
Populate the Control Data
w_sf_control-device = 'TELEFAX'.
w_sf_control-no_dialog = 'X'.
w_sf_control-langu = t_ctrl_app-spras.
Populate the Output Options.
w_output_options-tdteleland = lv_land1.
w_output_options-tdtelenum = lv_fax.
w_output_options-faxformat = 'PS'.
hope it works for u...
plz ping in for issues
Hi Durgaprasad,
Thank you for your suggestion. I will check that out.
As for now, my customer has changed his mind and decided that the mail should be sent to one recipient (department mail address) in outlook only. Therefore my problem can be solved using the standard mail functions provided with smartforms.
Thanks and best regards,
Tien
Hi Tien,
Have you ever figured out how to email invoice to multiple recipients? I have this requirement and posted in this forum but did not get any response. Thanks for your help.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.