Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Extremely Urgent: sending mails to External email ID

Former Member
0 Kudos

Hi All,

Iam working on a smartform and this smartform has to be send to External mails such as YAHOO, gmail,.etc.... apart from SAP email ID's.

Iam using the Function module "SO_NEW_DOCUMENT_ATT_SEND_API1" for sending the mails

The program sends mails only to SAP OUTBOX(Business Workplace) but not to external mails.

Below is my code: Please let me know what Iam missing in it.

Will definitely reward points if anything worthy.

Thanks and regards,

Shaan

CLEAR l_wa_reclist.

        • l_wa_reclist-receiver = 'xxxx.xxxx@sap.com'.

l_wa_reclist-receiver = 'xx_xxxx@yahoo.com'

l_wa_reclist-rec_type = 'U'.

  • l_wa_reclist-com_type = 'INT'.

  • l_wa_reclist-express = 'X'.

APPEND l_wa_reclist TO l_it_reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = l_wa_doc_chng

put_in_outbox = 'X'

    • IMPORTING

    • COMMIT_WORK = l_vflag

TABLES

packing_list = l_it_objpack

object_header = l_wa_objhead

contents_bin = l_it_objbin

contents_txt = l_it_objtxt

receivers = l_it_reclist

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.

ENDIF.

3 REPLIES 3

Former Member
0 Kudos

hi,

i think you need a littel help from your basis frnd, just check the SCOT settings,

krishnendu_laha
Active Contributor
0 Kudos

Hi Shaan,

Which function module ur using is used to send e-mail to SAP office.

Pleaes use function module <b>SO_OBJECT_SEND OR</b> <b>SO_DOCUMENT_SEND_API1</b>, to send e-mail to external address.

Regards

Krishnendu

hymavathi_oruganti
Active Contributor
0 Kudos
  • This example shows how to send

  • - a simple text provided in an internal table of text lines

  • - and an attached MS word document provided in internal table

  • - to some internet email address.

*

  • All activities done via facade CL_BCS!

DATA: send_request TYPE REF TO cl_bcs.

DATA: text TYPE bcsy_text.

data: binary_content type solix_tab.

DATA: document TYPE REF TO cl_document_bcs.

*DATA: sender TYPE REF TO cl_sapuser_bcs.

data: l_sender type ref to if_sender_bcs.

DATA: recipient TYPE REF TO if_recipient_bcs.

DATA: bcs_exception type ref to cx_bcs.

data: sent_to_all type os_boolean.

START-OF-SELECTION.

PERFORM main.

----


  • FORM main *

----


FORM main.

try.

  • -------- create persistent send request ------------------------

send_request = cl_bcs=>create_persistent( ).

  • -------- create and set document with attachment ---------------

  • create document from internal table with text

APPEND 'Hello world!' TO text.

document = cl_document_bcs=>create_document(

i_type = 'RAW'

i_text = text

i_length = '12'

i_subject = 'test created by BCS_EXAMPLE_2' ).

  • add attachment to document

  • BCS expects document content here e.g. from document upload

  • binary_content = ...

CALL METHOD document->add_attachment

EXPORTING i_attachment_type = 'DOC'

i_attachment_subject = 'My attachment'

i_att_content_hex = binary_content.

  • add document to send request

CALL METHOD send_request->set_document( document ).

  • --------- set sender -------------------------------------------

  • note: this is necessary only if you want to set the sender

  • different from actual user (SY-UNAME). Otherwise sender is

  • set automatically with actual user.

  • sender = cl_sapuser_bcs=>create( sy-uname).

l_sender = cl_cam_address_bcs=>create_internet_address(

'hymavathi.oruganti@hp.com' ).

CALL METHOD send_request->set_sender

EXPORTING i_sender = l_sender.

  • --------- add recipient (e-mail address) -----------------------

  • create recipient - please replace e-mail address !!!

recipient = cl_cam_address_bcs=>create_internet_address(

'hymavathi.oruganti@xyz.com' ).

  • add recipient with its respective attributes to send request

CALL METHOD send_request->add_recipient

EXPORTING

i_recipient = recipient

i_express = 'X'.

  • ---------- send document ---------------------------------------

CALL METHOD send_request->send(

exporting

i_with_error_screen = 'X'

receiving

result = sent_to_all ).

if sent_to_all = 'X'.

write text-003.

endif.

COMMIT WORK.

  • -----------------------------------------------------------

  • * exception handling

  • -----------------------------------------------------------

  • * replace this very rudimentary exception handling

  • * with your own one !!!

  • -----------------------------------------------------------

catch cx_bcs into bcs_exception.

write: 'Fehler aufgetreten.'(001).

write: 'Fehlertyp:'(002), bcs_exception->error_type.

exit.

endtry.

ENDFORM.