0% found this document useful (0 votes)
114 views4 pages

Abap Email

This document contains code for sending HTML formatted emails from SAP. It defines variables to store email data, text, and recipients. Forms are used to build the text message, including a header and body, and to define the list of email recipients. The code calls a FUNCTION to send the email with the formatted text and recipient list.

Uploaded by

Mauro Lopez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views4 pages

Abap Email

This document contains code for sending HTML formatted emails from SAP. It defines variables to store email data, text, and recipients. Forms are used to build the text message, including a header and body, and to define the list of email recipients. The code calls a FUNCTION to send the email with the formatted text and recipient list.

Uploaded by

Mauro Lopez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Report encargado de poder enviar los mails con formato HTML de salida, para poder

formatear el dise�o a nuestro gusto.

Esta configuraci�n depender� del navegador, unos trataran las instrucciones de una
manera

Creaci�n de variables....

**** datos para enviar mail

DATA: maildata LIKE sodocchgi1.


DATA: mailtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: mailrec LIKE somlrec90 OCCURS 0 WITH HEADER LINE.

**********LLamadas de form.

PERFORM enviar_mail.

***** Implementaci�n de c�digo.

******************************************************************

FORM enviar_mail.

CLEAR: maildata, mailtxt, mailrec.


REFRESH: mailtxt, mailrec.

***** lectura de la linea l_cdpos.

PERFORM build_text_message.

***** receptor del mail.

PERFORM build_receivers.

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.

ENDFORM. " enviar_mail

**************************************************************

FORM build_text_message.
**** aqui podemos montar la cabecera y el cuerpo del mail

PERFORM montar_cabebera.

PERFORM montar_cuerpo.

ENDFORM. " build_text_message

**************************************************************

FORM build_receivers.

***** para enviar por mail

* MOVE '[email protected]' TO mailrec-receiver.


* mailrec-rec_type = 'U'.
* APPEND mailrec.

***** para enviar una lista de distribuci�n

MOVE 'LISTADO_IT' TO mailrec-receiver.


mailrec-rec_type = 'C'.
APPEND mailrec.

ENDFORM. " build_receivers

**************************************************************

FORM montar_cabebera.

***************** creamos la cabecera del mail

DATA: texto(80) TYPE c.


CLEAR texto.

MOVE text-022 TO maildata-obj_name.

MOVE text-022 TO maildata-obj_descr.

mailtxt = '<HTML><HEAD>'.
APPEND mailtxt.
mailtxt = '<META HTTP-EQUIV="content-type" CONTENT="text/html;'
& 'charset=UTF-8"><FONT FACE="Arial Narrow" SIZE=3 '
& 'COLOR="#800080"></FONT></HEAD><BODY>'.
append mailtxt.

ENDFORM. " montar_cabebera

**************************************************************

FORM montar_cuerpo.

****** Configurar el cuerpo del mail.


**** Este ejemplo se crea un tabla para cargar datos.
DATA: linea(10) TYPE c,
n_linea TYPE n.

mailtxt = '<p class=MsoPlainText style=''text-align:justify''>'


& '<span style=''font-family:Arial''>'.
mailtxt = 'Estimado cliente'.
APPEND mailtxt.
mailtxt = '</span></p>'.
APPEND mailtxt.

mailtxt = '<p class=MsoPlainText style=''text-align:justify''>'


& '<span style=''font-family:Arial''>'.

APPEND mailtxt.
mailtxt = 'Le informamos que, con el prop�sito de mejorar nuestro
servicio, hemos implantado un Sistema de Comunicaci�n Activa' .
append mailtxt.
mailtxt = 'con todos nuestros clientes, gracias al cual usted puede
recibir informaci�n puntual sobre el estado de sus pedidos a trav�s'.
APPEND mailtxt.
mailtxt = 'de su correo electr�nico'.
APPEND mailtxt.
mailtxt = '</span></p>'.
APPEND mailtxt.

* mailtxt = '<TABLE>'.
* APPEND mailtxt.
*
* mailtxt = '<TR><TD witdh="100%" align=justify>'.
* APPEND mailtxt.
***** primera linea
* mailtxt = text-021.
* APPEND mailtxt.
* mailtxt = '<BR>'.
* APPEND mailtxt.
***** primer parrafo
* mailtxt = text-001.
* APPEND mailtxt.
* mailtxt = text-002.
* APPEND mailtxt.
* mailtxt = text-003.
* APPEND mailtxt.
* mailtxt = text-004.
* APPEND mailtxt.
* mailtxt = '<BR>'.
* APPEND mailtxt.
***** segundo parrafo
* mailtxt = text-005.
* APPEND mailtxt.
* mailtxt = text-006.
* APPEND mailtxt.
* mailtxt = text-007.
* APPEND mailtxt.
* mailtxt = '</TD></TR>'.
* APPEND mailtxt.
* mailtxt = '<BR>'.
* APPEND mailtxt.
****** texto del departamento
*
* mailtxt = '<TR><TD witdh="100%" align=center>'.
* APPEND mailtxt.
* mailtxt = text-008.
* APPEND mailtxt.
* mailtxt = text-009.
* APPEND mailtxt.
* mailtxt = text-010.
* APPEND mailtxt.
* mailtxt = text-011.
* APPEND mailtxt.
* mailtxt = '<BR>'.
* APPEND mailtxt.
* mailtxt = '</TD></TR>'.
* APPEND mailtxt.
*
*
* mailtxt = '<TR><TD width="100%" align=justify>'.
* APPEND mailtxt.
***** tercer parrafo
* mailtxt = text-012.
* APPEND mailtxt.
* mailtxt = text-013.
* APPEND mailtxt.
* mailtxt = text-014.
* APPEND mailtxt.
* mailtxt = text-015.
* APPEND mailtxt.
* mailtxt = text-016.
* APPEND mailtxt.
* mailtxt = text-017.
* APPEND mailtxt.
* mailtxt = text-018.
* APPEND mailtxt.
*
* mailtxt = '</TD></TR>'.
* APPEND mailtxt.
*
* mailtxt = '</TABLE>'.
* APPEND mailtxt.
*
* mailtxt = '<CENTER><A HREF="http://www.web.com" style="color:
*green; text-decoration:none">'.
* APPEND mailtxt.
* mailtxt = 'Noticias Empresa</a></center>'.
* APPEND mailtxt.
*
mailtxt = '</body>'.
append mailtxt.

mailtxt = '</html>'.
APPEND mailtxt.

ENDFORM. " montar_cuerpo

You might also like