paz
10/07/08, 08:14:35
Hola necesito enviar un correo. La función que utilizo para ello es:
FORM send_mail USING p_output STRUCTURE gw_output.
* Fill the document to send through Email-Sapmail.
DATA: objcont TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
doc_chng LIKE sodocchgi1.
doc_chng-sensitivty = 'P'.
*fill the document.
DATA: temp_string TYPE string.
DATA: temp_date TYPE string, temp_hour TYPE string.
MOVE 'Test' to temp_string.
doc_chng-obj_name = temp_string.
doc_chng-obj_descr = temp_string.
*message content
CLEAR: temp_string.
CONCATENATE 'Jobname: ' p_output-jobname
INTO temp_string SEPARATED BY space.
objcont = temp_string.
APPEND objcont.
CLEAR: temp_string.
CONCATENATE 'System: ' p_output-systemname
INTO temp_string SEPARATED BY space.
objcont = temp_string.
APPEND objcont.
*fill receiver list
* External adres: -> Type U, internal SAP -> Type B.
* List of receivers
reclist-receiver = p_adress.
reclist-rec_type = 'U'.
reclist-com_type = 'INT'.
APPEND reclist.
*send the document
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = doc_chng
"document_type = 'RAW'
"put_in_outbox = ' '
"commit_work = 'X'
TABLES
object_content = objcont
receivers = 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.
FORMAT COLOR 6.
WRITE: / 'Mail has not been sent!'.
FORMAT COLOR OFF.
MESSAGE x001(00) WITH 'Error sending mail.'.
ELSE.
FORMAT COLOR 5.
WRITE: /'Mail has been sent.'.
FORMAT COLOR OFF.
ENDIF.
ENDFORM. " send_mail
Pero siempre me saca el mensaje de document_not_sent = 2 he probado ya un monton de cosas pero nada me sirve. Estoy intentando mandar el mensaje a una cuenta de hotmail ...
Podríais ayudarme por favor?
Gracias ;)
FORM send_mail USING p_output STRUCTURE gw_output.
* Fill the document to send through Email-Sapmail.
DATA: objcont TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
doc_chng LIKE sodocchgi1.
doc_chng-sensitivty = 'P'.
*fill the document.
DATA: temp_string TYPE string.
DATA: temp_date TYPE string, temp_hour TYPE string.
MOVE 'Test' to temp_string.
doc_chng-obj_name = temp_string.
doc_chng-obj_descr = temp_string.
*message content
CLEAR: temp_string.
CONCATENATE 'Jobname: ' p_output-jobname
INTO temp_string SEPARATED BY space.
objcont = temp_string.
APPEND objcont.
CLEAR: temp_string.
CONCATENATE 'System: ' p_output-systemname
INTO temp_string SEPARATED BY space.
objcont = temp_string.
APPEND objcont.
*fill receiver list
* External adres: -> Type U, internal SAP -> Type B.
* List of receivers
reclist-receiver = p_adress.
reclist-rec_type = 'U'.
reclist-com_type = 'INT'.
APPEND reclist.
*send the document
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = doc_chng
"document_type = 'RAW'
"put_in_outbox = ' '
"commit_work = 'X'
TABLES
object_content = objcont
receivers = 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.
FORMAT COLOR 6.
WRITE: / 'Mail has not been sent!'.
FORMAT COLOR OFF.
MESSAGE x001(00) WITH 'Error sending mail.'.
ELSE.
FORMAT COLOR 5.
WRITE: /'Mail has been sent.'.
FORMAT COLOR OFF.
ENDIF.
ENDFORM. " send_mail
Pero siempre me saca el mensaje de document_not_sent = 2 he probado ya un monton de cosas pero nada me sirve. Estoy intentando mandar el mensaje a una cuenta de hotmail ...
Podríais ayudarme por favor?
Gracias ;)