Skip to Content
0
Former Member
Oct 20, 2004 at 06:21 AM

Problem while sending an email.

30 Views

Hi all,

I have copied an example program which is used to send Email to External Address.

But so far i am not able to recieve a mail in External address,

Can any body help me,

I have pasted the code below.

Thanks in Advance

Vinay.

Code:-

REPORT zvinay3 .

DATA: objcont LIKE solisti1 OCCURS 5 WITH HEADER LINE.

DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.

DATA: doc_chng LIKE sodocchgi1.

DATA: entries LIKE sy-tabix.

DATA: name(15).

  • Fill the document

doc_chng-obj_name = 'URGENT'.

doc_chng-obj_descr = 'Read at once !'.

doc_chng-sensitivty = 'P'.

objcont = 'Hey guys, time for lunch !!!'.

APPEND objcont.

objcont = 'Lets get going !'.

APPEND objcont.

DESCRIBE TABLE objcont LINES entries.

READ TABLE objcont INDEX entries.

doc_chng-doc_size = ( entries - 1 ) * 255 + STRLEN( objcont ).

  • Fill the receiver list

CLEAR reclist.

reclist-receiver = sy-uname. " replace with <login name>

reclist-rec_type = 'B'.

reclist-express = 'X'.

APPEND reclist.

CLEAR reclist.

reclist-receiver = 'vinay.br@sap.com'.

reclist-rec_type = 'U'.

APPEND reclist.

  • Send the document

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_type = 'RAW'

document_data = doc_chng

put_in_outbox = 'X'

TABLES

object_content = objcont

receivers = reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

CASE sy-subrc.

WHEN 0.

LOOP AT reclist.

IF reclist-receiver = space.

name = reclist-rec_id.

ELSE.

name = reclist-receiver.

ENDIF.

IF reclist-retrn_code = 0.

WRITE: / name, ': succesfully sent'.

ELSE.

WRITE: / name, ': error occured'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'Too many receivers specified !'.

WHEN 2.

WRITE: / 'No receiver got the document !'.

WHEN 4.

WRITE: / 'Missing send authority !'.

WHEN OTHERS.

WRITE: / 'Unexpected error occurred !'.

ENDCASE.