Ver Mensaje Individual
  #2  
Viejo 22/03/06, 15:12:40
reijimher reijimher is offline
El más rápido del oeste
 
Fecha de Ingreso: mar 2006
Localización:
Mensajes: 93
Thumbs up

Hola Alicia, para enviar un formulario a través del correo electrónico, primero tienes que convertirlo a formato PDF, esto lo puedes lograr por la función que a continuación te describo:

1 -
*****************************************************************************
* VERIFICA EL TIPO DE SPOOL QUE TENEMOS
*****************************************************************************

call function 'RSPO_GET_TYPE_SPOOLJOB'
exporting
rqident = spool_id
importing
is_otf = i_otf
exceptions
can_not_access = 1
others = 2.
if sy-subrc <> 0.
message id 'Z1' type 'E' number 000
with text-002.
elseif i_otf eq 'X'.

*****************************************************************************
* Generar PDF de OTF
*****************************************************************************
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
exporting
src_spoolid = spool_id
importing
pdf_bytecount = pbyte
tables
pdf = t_pdf
exceptions
err_no_otf_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
others = 12.
else. " Generar PDF de Abap

call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = spool_id
importing
pdf_bytecount = pbyte
tables
pdf = t_pdf
exceptions
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
others = 12.
if sy-subrc eq 0.
* Iniciamos la traducción por error en la funcion de conversion ABAP-PDF
loop at t_pdf into i_pdf.
translate i_pdf using ',.'.
modify t_pdf from i_pdf.
endloop.
endif.
endif. "De if sy-subrc


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

2- Bajas el PDF Generado a Disco

concatenate subdir '\' p_file '.PDF' into w_archivo.


call function 'WS_DOWNLOAD'
exporting
bin_filesize = pbyte
filename = w_archivo
filetype = 'BIN'
tables
data_tab = t_pdf
exceptions
invalid_filesize = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6.

if sy-subrc <> 0.
message id 'Z1' type 'E' number '000' with text-003.
endif.

endform. " BAJAR_ARCHIVO

**********************************************************************************************
3- Buscas las Direcciones de Email en el Maestro de Proveedores

select single * from lfa1 where lifnr eq report_iii-lifnr.
if sy-subrc = 0.
select single * from adr6 where addrnumber = lfa1-adrnr.
if sy-subrc = 0.
p_to = adr6-smtp_addr.
else.
p_to = space.
message i999 with text-012 lfa1-adrnr text-013.
endif.
endif.

**************************************************************************************************
4- Envías el Correo a través de las siguiente instrucciones

data: appoutlook type ole2_object.
data: appout2 type ole2_object.
data: appitem type ole2_object.
data: namespace type ole2_object.
data: attachments type ole2_object.
data: frace01(45), frace02(45).
* Crear objeto OLE : outlook.application
create object appoutlook 'outlook.application' .
* Mensajes vía MAPI
call method of appoutlook 'GetNameSpace' = namespace
exporting #1 = 'MAPI'.
* Crea objeto nuevo ITEM ( nuevo mensaje )
call method of appoutlook 'CreateItem' = appitem
exporting #1 = '0'.
* Propiedades TO , SUBJECT y BODY
set property of appitem 'To' = 'xxxxxxx@xxx.com'.


concatenate p_subj 'OI' into p_subj separated by space.
set property of appitem 'Subject' = p_subj.

set property of appitem 'Body' = ‘Adjunto, Pedidos’.
* Se adjunta el archivo
if not w_archivo is initial.
call method of appitem 'Attachments' = attachments.
call method of attachments 'Add'
exporting #1 = w_archivo.
endif.

* Envíar directamente
call method of appitem 'Send'.
*Se muestra la pantalla del outlook
******** CALL METHOD OF appitem 'Display'.
* Libera Espacio del objeto
free object attachments.
free object appitem.
free object namespace.
* Cierra Outlook ( solo si se quiere que quede cerrado )
***CALL METHOD OF appoutlook 'Quit'.
free object appoutlook.


Espero que esto te ayude


Saludos....

Reiner Jiménez