Skip to Content
author's profile photo Former Member
Former Member

Problem while sending the mail from sap

Hi experts,

I am facing some problem while sending mail from sap to external mail.

this is th code i am using but it is not working. plz check and tell me.

REPORT ZMAIL_DEMO.

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.

break-point.

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 = 'SOME MAIL ID'.

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. "( did not receive any mail) *

write : 'mail sent'.

endif.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2008 at 12:24 PM

    Assuming all the data that is being passed correct, I would check SCOT transaction to see any pending requests. Push it from there if you have any pending request. (this is for external mail)

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2008 at 12:28 PM

    After executing ur program run RSCONN01 or u can schedule RSCONN01 to run in background....

    Regards,

    Joy.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 13, 2008 at 12:29 PM
    if sy-subrc = 0. "( did not receive any mail) *
    write : 'mail sent'.
    endif

    what is the sy-subrc value. Is SCOT settings for sending external mails are properly done.

    if sy-subrc eq 0 then you check any mail are queue . if so then manually send them .

    do this also.

    if  sy-subrc eq 0.
    
    commit work.
    call function 'SO_DEQUEUE_UPDATE_LOCKS'.
    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2008 at 12:34 PM

    Hi,

    Please check with the following code.

    TABLES: KNA1.

    • data for send function

    DATA DOC_DATA LIKE SODOCCHGI1.

    DATA OBJECT_ID LIKE SOODK.

    DATA OBJCONT LIKE SOLI OCCURS 10 WITH HEADER LINE.

    DATA RECEIVER LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE.

    SELECT * FROM KNA1 WHERE ANRED LIKE 'C%'.

    WRITE:/ KNA1-KUNNR, KNA1-ANRED.

    • send data internal table

    CONCATENATE KNA1-KUNNR KNA1-ANRED

    INTO OBJCONT-LINE SEPARATED BY SPACE.

    APPEND OBJCONT.

    ENDSELECT.

    • insert receiver (sap name)

    REFRESH RECEIVER.

    CLEAR RECEIVER.

    MOVE: 'any_email'_ TO RECEIVER-RECEIVER, " SY-UNAME

    'X' TO RECEIVER-EXPRESS,

    'U' TO RECEIVER-REC_TYPE.

    APPEND RECEIVER.

    • insert mail description

    WRITE 'Sending a mail through abap'

    TO DOC_DATA-OBJ_DESCR.

    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

    EXPORTING

    DOCUMENT_DATA = DOC_DATA

    IMPORTING

    NEW_OBJECT_ID = OBJECT_ID

    TABLES

    OBJECT_CONTENT = OBJCONT

    RECEIVERS = RECEIVER

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.