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: 

Sending mail as message

Former Member
0 Kudos

Hi all,

I need a functionality of sending mail as a text in the mail itself. Means I want all the internal table data to be sent as a message in the mail and no attachment needed. Has any body faced such issue, please do reply....

I tried to use FM SO_API_NEW_DOCUMENMT_API1, without specifying attachment type and file name... But this FM returns with sy-subrc = 2 (No Document Sent)

regards,

Saurabh Garg

11 REPLIES 11

Former Member
0 Kudos

put all the data in <b>objtxt</b>.

OBJTEXT is nothing but BODY of mail.

regards

Prabhu

Former Member
0 Kudos

call function 'SO_NEW_DOCUMENT_SEND_API1'

exporting

DOCUMENT_TYPE = 'RAW'

DOCUMENT_DATA = IS_DOCDATA

  • PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

tables

OBJECT_CONTENT = IT_CONTENT

RECEIVERS = IT_RECEIVERS

exceptions

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

others = 99.

Regards

Anurag

former_member184619
Active Contributor
0 Kudos

Here is the FM

'SO_NEW_DOCUMENT_SEND_API1'

U can check it's documentation for more details

even a sample program is there.

Copy it and check it.

OR CHECK THe reciver list :-

CLEAR RECLIST.

RECLIST-RECEIVER = SY-UNAME. "SAP logon NAme

RECLIST-REC_TYPE = 'B'. "For Internal mails

RECLIST-EXPRESS = 'X'.

APPEND RECLIST.

CLEAR RECLIST.

RECLIST-RECEIVER = 'SDHINGRA_83@YAHOO.CO.IN'.

RECLIST-REC_TYPE = 'U'. "For external ID

APPEND RECLIST

Use Rec_type = 'U'. and reciver = 'name@some.com' ONLY

In case u r sending it to externl id

Reward points if helpful.

Regards

-


Sachin Dhingra

Message was edited by: Sachin Dhingra

former_member480923
Active Contributor
0 Kudos

Hi

Try this code out

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
         EXPORTING
              document_data              = wal_docdata
              put_in_outbox              = c_check
         TABLES
              packing_list               = t_objpack
              contents_txt               = t_content_txt
              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.

Here the table t_content_txt is the report body

Hope This Helps

Anirban

Former Member
0 Kudos

this program is used to send mails to the users internet mail addresses.

REPORT ZSRIM_PRG_MAIL1 .

DATA : L_TABLE_LINES LIKE SY-TABIX, " table index

L_TAB TYPE X VALUE '09', " TAB value

L_MANDT TYPE SY-MANDT. " Client

DATA: X_DOC_CHNG LIKE SODOCCHGI1, " document attributes

IT_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,

" attachment table

IT_OBJHEAD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

" object header table

IT_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

" binary table

IT_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

IT_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.

CLEAR IT_RECLIST.

REFRESH IT_RECLIST.

*-popualate email ids

IT_RECLIST-RECEIVER = 'ABC@YAHOO.com'.

IT_RECLIST-REC_TYPE = 'U'.

*-append receiver table

APPEND IT_RECLIST.

CLEAR IT_RECLIST.

*-populate document attributes

CLEAR: X_DOC_CHNG.

X_DOC_CHNG-OBJ_NAME = 'HEADING'.

X_DOC_CHNG-OBJ_DESCR = 'SOME DESCRIPTION'.

<b>*-populate body text

LOOP AT ITAB.

CONCATENATE ITAB-FIELD1

ITAB-FIELD2

INTO IT_OBJTXT.

APPEND IT_OBJTXT.

ENDLOOP.</b>

*-document size

CLEAR : L_TABLE_LINES.

DESCRIBE TABLE IT_OBJTXT LINES L_TABLE_LINES.

READ TABLE IT_OBJTXT INDEX L_TABLE_LINES.

X_DOC_CHNG-DOC_SIZE =

( L_TABLE_LINES - 1 ) * 255 + STRLEN( IT_OBJTXT ).

*-populate packing list for body text

CLEAR IT_OBJPACK-TRANSF_BIN.

IT_OBJPACK-HEAD_START = 1.

IT_OBJPACK-HEAD_NUM = 0.

IT_OBJPACK-BODY_START = 1.

IT_OBJPACK-BODY_NUM = L_TABLE_LINES.

IT_OBJPACK-DOC_TYPE = 'RAW'.

APPEND IT_OBJPACK.

CLEAR IT_OBJPACK.

*-populate object header

IT_OBJHEAD = 'headings'(057).

APPEND IT_OBJHEAD.

CLEAR IT_OBJHEAD.

*-Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = X_DOC_CHNG

PUT_IN_OUTBOX = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

  • PACKING_LIST = IT_OBJPACK

OBJECT_HEADER = IT_OBJHEAD

CONTENTS_BIN = IT_OBJBIN

CONTENTS_TXT = IT_OBJTXT

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

RECEIVERS = 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.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Former Member
0 Kudos

Hi Please check this code.

which is similar to your requirement.

form process_text_message.

clear T_MAILTXT.

refresh t_mailtxt.

  • get the transaction no.

  • preparation of the Subject

*W_MAILDATA-OBJ_NAME = 'TEST'.

*concatenate 'Cir Case ID-' t_changedtimestamp_guid-extern_act_id

*into W_MAILDATA-OBJ_DESCR.

*W_MAILDATA-OBJ_LANGU = SY-LANGU.

*write sy-datum to w_date DD/MM/YYYY.

*concatenate

*'The following are CIR transactions changed to the status'

*'''COMPLETED'''

*'on :'

*w_date

*into T_MAILTXT-LINE.

*append T_MAILTXT.

*CLEAR T_MAILTXT.

*APPEND T_MAILTXT.

*APPEND T_MAILTXT.

*

  • filling all the competed satus records

*loop at t_changedtimestamp_guid.

*

*CALL FUNCTION 'CRM_STATUS_READ'

  • EXPORTING

  • CLIENT = SY-MANDT

  • OBJNR = t_changedtimestamp_guid-guid

  • ONLY_ACTIVE = 'X'

    • IMPORTING

    • OBTYP =

    • STSMA =

    • STONR =

    • ET_JEST_BUF =

  • TABLES

  • STATUS = t_status

  • EXCEPTIONS

  • OBJECT_NOT_FOUND = 1

  • OTHERS = 2

  • .

*IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

*

*read table t_status with key stat = 'E0003' .

*if sy-subrc = 0.

*counter = counter + 1.

*clear w_temp_char.

*w_temp_char = counter.

*concatenate w_temp_char ') '

*''''

*t_changedtimestamp_guid-object_id

*''''

*into

*T_MAILTXT-LINE.

*WRITE 😕 T_MAILTXT-LINE.

*append T_MAILTXT.

*clear T_MAILTXT.

*endif.

*

*clear t_changedtimestamp_guid.

*clear t_status.

*refresh t_status.

*endloop.

*if counter le 0.

*CONCATENATE 'There are no CIRcases whose status changed to'

*'''COMPTELETED''' 'ON' w_date INTO T_MAILTXT-LINE.

*APPEND T_MAILTXT.

*clear t_mailtxt.

*endif.

    • filling the Salutation

*APPEND T_MAILTXT.

*APPEND T_MAILTXT.

*T_MAILTXT-LINE = 'Regards,'.

*Append T_MAILTXT.

*T_MAILTXT-LINE = 'The Representative'.

*append T_MAILTXT.

clear w_maildata.

W_MAILDATA-OBJ_NAME = 'TEST'.

concatenate 'CIR Case ID-' t_changedtimestamp_guid-extern_act_id

into W_MAILDATA-OBJ_DESCR.

W_MAILDATA-OBJ_LANGU = SY-LANGU.

T_MAILTXT-LINE = 'To,'.

append t_mailtxt.

clear t_mailtxt.

concatenate t_changedtimestamp_guid-duns_name_last

t_changedtimestamp_guid-duns_name_last into T_MAILTXT-LINE

separated by space.

append t_mailtxt.

clear t_mailtxt.

append t_mailtxt.

  • adding the customer notes.

clear lt_customer_notes.

refresh lt_customer_notes.

lt_customer_notes[] = t_changedtimestamp_guid-customer_notes[].

loop at lt_customer_notes.

T_MAILTXT-LINE = lt_customer_notes-tdline.

append T_mailtxt.

clear t_mailtxt.

clear lt_customer_notes.

endloop.

append t_mailtxt. "blank line

T_MAILTXT-LINE = 'From,'.

append t_mailtxt.

clear t_mailtxt.

concatenate t_changedtimestamp_guid-closed_by_name_first

t_changedtimestamp_guid-closed_by_name_last into T_MAILTXT-LINE

separated by space.

append t_mailtxt.

clear t_mailtxt.

append t_mailtxt.

endform.

form process_receivers.

clear T_MAILREC.

*T_MAILREC-receiver = 'JAFFER.VALI@LNTINFOTECH.COM'.

T_MAILREC-receiver = p_email.

T_MAILREC-rec_type = 'U'.

T_MAILREC-notif_read = 'X'.

T_MAILREC-com_type = 'INT'.

T_MAILREC-notif_del = 'X'.

T_MAILREC-notif_ndel = 'X'.

APPEND T_MAILREC.

endform.

FORM SEND_MAIL_NODIALOG.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = W_MAILDATA

DOCUMENT_TYPE = 'RAW'

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

OBJECT_HEADER = T_MAILTXT

OBJECT_CONTENT = T_MAILTXT

RECEIVERS = T_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 e002.

ELSE.

wait up to 2 seconds.

submit rsconn01 with mode = 'INT'

with output = ''

and return.

ENDIF.

commit work.

ENDFORM.

Former Member
0 Kudos

Hi Saurabh,

I guess the problem is with the recepients mail address. Did you inlcude the mail address say '@yahoo.com' in the transaction SCOT.

If not ...SCOT->double click SMTP->click on SET(Internet) and inlude '@yahoo.com' in the address area.

Hope this helps,

Regards,

Vidya.

0 Kudos

hI vIDYA ,

after ur post , i done the changes in SCOT but i am getting log

No delivery to , as recipient unknown
Message no. XS802

Diagnosis
The message from the node could not be delivered to recipient  as the recipient is unknown.

System Response
Processing was ended normally.

Additional information of the node used (in the system language of the node):
550 5.7.1 Unable to relay for rao_peram@YAHOO.COM 

Procedure
Check the recipient address, correct if necessary and send the message to the correct address.
If the node is an R/3 System, the address  is not contained in address management or SAPoffice exception management. In this case, you should maintain the address here.
If the node is not an R/3 System, you must maintain the address in the appropriate system.

Regards

Prabhu

Former Member
0 Kudos

Hi Prabhu,

Guess you have given the whole address rao_peram@YAHOO.COM .

Just give @YAHOO.COM.....

Regards,

Vidya

minerva_paredes
Explorer
0 Kudos

Hi basis experts,

I try send mail from sap to external email.

I have a SMTP server and I configured the next parameters in tx SCOT

Mail host:smtp.sponsor.com.mx

Mail port:25

Code page:UTF-8

The settings for internet

Address areas:

*

'@HOTMAIL.COM'

And the test to SMTP server of the note 439948 was succesfull.

220 Welcome ESMTP server ready Tue, 19 Dec 2006 15:47:08 -0600

EHLO sponsor.com.mx

250-apk1fe17.mail2.triara.com

250-HELP

250-XREMOTEQUEUE

250-ETRN

250-AUTH=LOGIN

250-AUTH LOGIN

250-DSN

250 SIZE 31211520

MAIL FROM:minerva_paredes@sponsor.com.mx ENVID=12345

250 Sender <> Ok

quit

221 Closing connection. Good bye.

But when I send a message to e-mail mpdina55@hotmail.com the system sends the next message

No delivery to minerva, as recipient unknown

Message no. XS802

Diagnosis

The message from the node could not be delivered to recipient minerva as the recipient is unknown.

System response

Processing was ended normally.

Additional information of the node used (in the system language of the node):

_553 Authentication is required to send mail as <m

Procedure

Check the recipient address, correct if necessary and send the message to the correct address.

If the node is an R/3 System, the address minerva is not contained in address management or SAPoffice exception management. In this case, you should maintain the address here.

If the node is not an R/3 System, you must maintain the address in the appropriate system.

Please HELP ME.

Regards.

Minerva Paredes

0 Kudos

Has anyone known the solutions of this message XS802?

I have the same problem with Minerva, where all setting has been maintained properly, but still error message XS802 appears.

Thanks,

Yulianto