cancel
Showing results for 
Search instead for 
Did you mean: 

e-mail without Outlook

Former Member
0 Kudos

hi

i want to send and e-mail from abap code. I looked up some examples but all of them put the Outlook as a default browser. Instead of Outlook I want to put another one, ( the default browser in your Internet´s configuration) for example GroupWise

thanks.

Accepted Solutions (1)

Accepted Solutions (1)

emjay
Active Participant
0 Kudos

If you want to send email out of SAP then SMTP has to be configured in SAP. Using the FM the recepient's email address can be an internet address or an internal outlook address.

Hope this helps.

EmJay

-


Assign Points if useful

Answers (6)

Answers (6)

Former Member
0 Kudos

when i go to TX SO01, the status of the message is in yellow....why??

former_member191977
Contributor
0 Kudos

submit rsconn01 with mode = 'INT'

with output = 'X'

and return.

submit this. some times it takes time to trigger this program. if you do it in your program it will be quicker.

award points if it helps.

Former Member
0 Kudos

when i use the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'

i have to configurate the SMTP in SAP????

Former Member
0 Kudos

Hi,

Look at the below sample code

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

PARAMETERS: psubject(40) type c default  'Hello',
            p_email(40)   type c default 'test@sapdev.co.uk' .

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 'Email line 1' to it_message.
  Append 'Email line 2' to it_message.
  Append 'Email line 3' to it_message.
  Append 'Email line 4' 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
  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'.
  it_receivers-com_type = 'INT'.
  it_receivers-notif_del = 'X'.
  it_receivers-notif_ndel = 'X'.
  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

Regards

Sudheer

former_member191977
Contributor
0 Kudos

Hi Leonel,

Using the FM you can send email to any internet account. Check this code...

  • For Run Date

WRITE sy-datum TO v_date1.

  • Creation of the document to be sent

x_doc_chng-obj_name = sy-datum.

x_doc_chng-obj_descr = 'GL Daily Revenue Feed'(061).

CONCATENATE 'Run date :'(062) v_date1 INTO

v_msgbody SEPARATED BY space.

i_objtxt = v_msgbody.

APPEND i_objtxt.

i_objtxt = space.

APPEND i_objtxt.

IF i_message[] IS INITIAL.

CONCATENATE 'There are no Kiosks in error today. Location:'(030)

p_fname

INTO i_objtxt SEPARATED BY space.

ELSE.

CONCATENATE 'Pls. find attached the log for GL Daily Revenue Feed. Location:'(030)

p_fname

INTO i_objtxt SEPARATED BY space.

ENDIF.

APPEND i_objtxt.

DESCRIBE TABLE i_objtxt LINES v_tab_lines.

READ TABLE i_objtxt INDEX v_tab_lines.

x_doc_chng-doc_size =

( v_tab_lines - 1 ) * 255 + STRLEN( i_objtxt ).

  • Creation of the entry for the compressed document

CLEAR i_objpack-transf_bin.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

i_objpack-body_num = v_tab_lines.

i_objpack-doc_type = 'RAW'.

APPEND i_objpack.

DESCRIBE TABLE i_objbin LINES i_objpack-body_num.

i_objpack-transf_bin = 'X'.

i_objpack-head_start = 1.

i_objpack-head_num = 1.

i_objpack-body_start = 1.

i_objpack-doc_size = i_objpack-body_num * 255.

i_objpack-doc_type = 'XLS'.

i_objpack-obj_descr =

'Log Details for GL Daily Revenue Feed'(063).

APPEND i_objpack.

CLEAR i_objpack.

LOOP AT s_email.

i_reclist-receiver = s_email-low.

i_reclist-rec_type = 'U'.

APPEND i_reclist.

CLEAR i_reclist.

ENDLOOP.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = x_doc_chng

commit_work = 'X'

TABLES

packing_list = i_objpack

object_header = i_objheader

contents_bin = i_objbin

contents_txt = i_objtxt

receivers = i_reclist

EXCEPTIONS

too_many_receivers = 10

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

IF sy-subrc NE 0.

MESSAGE i000 WITH

'Error in sending Log Details'(064).

ENDIF.

CLEAR : i_objbin.

REFRESH : i_objbin.

Award points if it helps.

Former Member
0 Kudos

Hi,

Try with this....FM 'UWSP_SEND_MAIL_TO_WEB'

Former Member
0 Kudos

Hi,

I am not sure what you are looking for..But check this example for sending email from abap code..

  • Declarations.

PARAMETERS: p_email(50) LOWER CASE.

DATA: document_data LIKE sodocchgi1.

DATA: t_content LIKE STANDARD TABLE OF solisti1.

DATA: s_content LIKE solisti1.

DATA: t_receivers LIKE STANDARD TABLE OF somlreci1.

DATA: s_receivers LIKE somlreci1.

START-OF-SELECTION.

  • Receivers.

s_receivers-receiver = p_email.

s_receivers-rec_type = 'U'.

s_receivers-express = 'X'.

APPEND s_receivers TO t_receivers.

  • Subject

document_data-obj_descr = 'New mail from Sap'.

  • Body

s_content = 'Hi,'.

APPEND s_content TO t_content.

CLEAR: s_content.

APPEND s_content TO t_content.

s_content = 'Test email from sap, please don''t reply to this email'.

APPEND s_content TO t_content.

CLEAR: s_content.

APPEND s_content TO t_content.

s_content = 'Thanks,'.

APPEND s_content TO t_content.

s_content = 'Naren.'.

APPEND s_content TO t_content.

  • Send the email.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = document_data

TABLES

object_content = t_content

receivers = t_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.

IF sy-subrc <> 0.

MESSAGE e208(00) WITH 'Error in sending email :-(('.

ELSE.

MESSAGE s208(00) WITH 'Email sent )'.

ENDIF.

SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.

Thanks

Naren