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: 

SAP Email

Former Member
0 Kudos
175

Hi All,

Iam using SO_DOCUMENT_SEND_API1 to send email from SAP. The problem is when i released using SOST Tcode status text is " No delivery to sender address invalid recipient" i think this is because of i did't not maintain RFC destination for sender address...here is the code... for sendaddress iam concatenating sysid and objid...i think i want to maintain RFC for objid to identify the sender...

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

sender_address = sendaddress

sender_address_type = 'SMTP'

Can anyone give me the solution...

7 REPLIES 7

Former Member
0 Kudos
88

Hi,

this may help you.

/people/thomas.jung3/blog/2004/09/07/sending-e-mail-from-abap--version-46d-and-lower--api-interface

/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html

http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp

reward points for helpfull answers and close the thread if your question is solved.

regards,

venu.

Former Member
0 Kudos
88

Hi Madhu,

Just test this sample code to send a mail.


*&---------------------------------------------------------------------*
*& Report  ZSENDEMAIL                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*& Example of sending external email via SAPCONNECT                    *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT  zsendemail                    .

PARAMETERS: psubject(40) type c default  'Testing',
            p_email(40)   type c default 'anjali.devi@wipro.com'.

data:   it_packing_list like sopcklsti1 occurs 0 with header line,
        it_contents like solisti1 occurs 0 with header line,
        it_receivers like somlreci1 occurs 0 with header line,
        it_attachment like solisti1 occurs 0 with header line,
        gd_cnt type i,
        gd_sent_all(1) type c,
        gd_doc_data like sodocchgi1,
        gd_error type sy-subrc.

data:   it_message type standard table of SOLISTI1 initial size 0
                with header line.

***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.

Perform populate_message_table.

*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.

*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.


*&---------------------------------------------------------------------*
*&      Form  POPULATE_MESSAGE_TABLE
*&---------------------------------------------------------------------*
*       Adds text to email text table
*----------------------------------------------------------------------*
form populate_message_table.
  Append 'Line1' to it_message.
  Append 'Line2' to it_message.
  Append 'Line3' to it_message.
  Append 'Test- 1' to it_message.
endform.                    " POPULATE_MESSAGE_TABLE


*&---------------------------------------------------------------------*
*&      Form  SEND_EMAIL_MESSAGE
*&---------------------------------------------------------------------*
*       Send email message
*----------------------------------------------------------------------*
form send_email_message.
* Fill the document data.
  gd_doc_data-doc_size = 1.

* Populate the subject/generic message attributes
  gd_doc_data-obj_langu = sy-langu.
  gd_doc_data-obj_name  = 'SAPRPT'.
  gd_doc_data-obj_descr = psubject.
  gd_doc_data-sensitivty = 'F'.

* Describe the body of the message
* Information about structure of data tables
  clear it_packing_list.
  refresh it_packing_list.
  it_packing_list-transf_bin = space.
  it_packing_list-head_start = 1.
  it_packing_list-head_num = 0.
  it_packing_list-body_start = 1.
  describe table it_message lines it_packing_list-body_num.
  it_packing_list-doc_type = 'RAW'.
  append it_packing_list.

* Add the recipients email address
  clear it_receivers.
  refresh it_receivers.
  it_receivers-receiver = p_email.
  it_receivers-rec_type = 'U'.
  append it_receivers.

* Call the FM to post the message to SAPMAIL
  call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       exporting
            document_data              = gd_doc_data
            put_in_outbox              = 'X'
       importing
            sent_to_all                = gd_sent_all
       tables
            packing_list               = it_packing_list
            contents_txt               = it_message
            receivers                  = it_receivers
       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.

* Store function module return code
  gd_error = sy-subrc.

* Get it_receivers return code
  loop at it_receivers.
  endloop.
endform.                    " SEND_EMAIL_MESSAGE


*&---------------------------------------------------------------------
*&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
*&---------------------------------------------------------------------
*       Instructs mail send program for SAPCONNECT to send email.
*----------------------------------------------------------------------

form initiate_mail_execute_program.
  wait up to 2 seconds.
  if gd_error eq 0.
      submit rsconn01 with mode = 'INT'
                    with output = 'X'
                    and return.
  endif.
endform.                  "INITIATE_MAIL_EXECUTE_PROGRAM

And let us know if its working fine for you.

Regards,

Anjali

Former Member
0 Kudos
88

please post whole code if possible

regards

i think you have to put select to get user's SMTP from USR6

0 Kudos
88

Hi,

My problem is in FM for exporting parameter sender_address, if assign say "latha@in.ibm.com" it is working fine, if i assign say "Sysid+objid", iam getting errow while releasing using SOST

Tcode saying receipent not available...means i have to maintian sender address for this objid in RFC Destination....i have no issues about FM, only issue with exporting parameter sendr_address avilability...this my problem..i think now it is clear...

0 Kudos
88

try SCOT for sending mails

how to configure SCOT , you can find thread on forum

i don't think it is problem with SOST.

put watchpoint of smtp address

regards

0 Kudos
88

Hello Madhu,

did your problem got solved

if yes then pls share what was problem and close thread

regards