Application Development and Automation 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: 
Read only

Function Module to send email

Former Member
0 Likes
5,280

Hi All,

Is there a Function Module in R/3 that can send external emails?

Thanks!

Roman D.

10 REPLIES 10
Read only

Former Member
0 Likes
1,413

Roman,

Use FM SO_OBJECT_SEND.

The FM is used extensively in SAP and finding examples should be easy.

Rishi

Read only

0 Likes
1,413

Thanks Rishi!

Read only

0 Likes
1,413

I usually use the following function module. I believe that it eventually calls the function module mentioned in the previous post. Here is a sample program.



report zrich_0003 .

data: maildata type sodocchgi1.
data: mailtxt  type table of solisti1 with header line.
data: mailrec  type table of somlrec90 with header line.

start-of-selection.

  clear:    maildata, mailtxt,  mailrec.
  refresh:  mailtxt, mailrec.

  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test'.
  maildata-obj_langu = sy-langu.

  mailtxt-line = 'This is a test'.
  append mailtxt.

  mailrec-receiver = 'someone@somewhere.com'.
  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.
  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

Regards,

Rich Heilman

Read only

Prajesh
Product and Topic Expert
Product and Topic Expert
0 Likes
1,413

Hi Rich,

I tried to send a mail to my external mail box using the code segment you have given. But I didn't receive the mail which I had send. Could you please tell me whether I need to do any configuration or something like that for this program to work

Read only

0 Likes
1,413

Hi Prajesh,

so what's your problem exactly ?

you'll send mail from SAP to outlook / webmail ?

-> so look <b>weblog</b> of Thomas Jung:

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                     = html_tab
      contents_txt                     = objtxt
      receivers                        = reclist

...

regards Andreas

Read only

Prajesh
Product and Topic Expert
Product and Topic Expert
0 Likes
1,413

Hi Andreas,

exactly i want to send mail from SAP to outlook or any other external mail system.could you please tell me what are all things I should taken care?

Read only

0 Likes
1,413

Hi Prajesh,

Have you configured SAP to talk to an external mail system?

You can do this using SAPConnect (transaction SCOT).

You will need to set up an internet node (you can connect to the mail server using RFC, and also HTTP from 6.2 onwards).

Once you have done this, you will be able to send mail to your outlook.

To look at your 'stuck' messages (the ones that you have sent, but which have not gone anywhere), run transaction SOST.

Cheers,

Brad

Read only

ramki_maley
Active Contributor
0 Likes
1,413

Rich is right. You should use SO_NEW_DOCUMENT_SEND_API1 or SO_NEW_DOCUMENT_ATT_SEND_API1 if you want to send attachments along with the mail. These modules are released for customer use and have very good documentation.

Also please see the Weblogs mentioned below:

Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface: /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

Sending E-Mail from ABAP - Version 46D and Lower - API Interface: /people/thomas.jung3/blog/2004/09/07/sending-e-mail-from-abap--version-46d-and-lower--api-interface

Cheers,

Ramki.

Read only

Former Member
0 Likes
1,413

Using call function "SO_NEW_DOCUMENT_ATT_SEND_API1" in specific program in SAP R/3, i would like to know if it is possible to send a mail on Outlook webmail box in 4.0B Version of SAP?

Regards, Vincent

Read only

Former Member
0 Likes
1,413

Roman;

Try adding this section of code to the end of Rich's example:

SUBMIT rsconn01 WITH mode = 'INT'

WITH output = 'X'

EXPORTING LIST TO MEMORY

AND RETURN.

If that doesn't work, I concur with Brad that there may be a problem that you can track down in transactions SCOT or SOST.

-John