Adjuntar archivo usando bbj email services

49 views
Skip to first unread message

César Suasnávar

unread,
Jul 15, 2022, 5:19:46 PM7/15/22
to MundoBBx
Buenas tardes, en el enterprise manager definí un email service, y puedo enviar correos usando el ejemplo de esta página: https://documentation.basis.cloud/BASISHelp/WebHelp/javadocs/com/basis/api/admin/BBjAdminEmailService.html
Sin embargo no logro adjuntar archivos, en la página https://documentation.basis.cloud/BASISHelp/WebHelp/javadocs/com/basis/api/admin/BBjAdminEmailAttachment.html#BBjAdminEmailAttachment-- está la documentación referente a la clase BBjAdminEmailAttachment pero no consigo implementarla, alguien tendrá algún ejemplo de como implementarlo?

Gracias de antemano.

Saludos!

José Aguilar

unread,
Jul 15, 2022, 6:00:23 PM7/15/22
to MundoBBx
Hola César,

Yo usé este código para preparar un correo con adjuntos usando Email Service. Espero te ayude.

Saludos cordiales,

Administrador MundoBBx

use com.basis.api.admin.BBjAdminEmailService 
use com.basis.api.admin.BBjAdminEmailMessage
use com.basis.api.admin.BBjAdminEmailAttachment
declare BBjAdminBase api! 
declare BBjAdminList emailServices! 
declare BBjAdminEmailService emailSvc! 
declare BBjAdminEmailService selectedEmailSvc! 
declare BBjAdminEmailMessage msg!
declare BBjAdminEmailAttachment attachment1!
declare BBjAdminEmailAttachment attachment2!
api!=BBjAdminFactory.getBBjAdmin("admin","admin123")
rem
emailServices! = api!.getEmailServices()
rem
for i=0 to emailServices!.size()-1
    emailSvc!=cast(BBjAdminEmailService, emailServices!.get(i))
    if emailSvc!.getString(BBjAdminEmailService.NAME)="NombreDeMiEmailService" then correo_seleccionado=i; break endif
next i
selectedEmailSvc!=cast(BBjAdminEmailService, emailServices!.get(correo_seleccionado))
rem
correo:
gosub verifica_correo
test=0
msg!=selectedEmailSvc!.createMessage()
subject$="(TEST) Ejemplo de envio de correo"
msg!.setString(BBjAdminEmailMessage.SUBJECT, subject$)
gosub msghtml
if len(msghtml$)=0 then
    msgtext$="Mensaje plano"
    msg!.setString(BBjAdminEmailMessage.TEXT, msgtext$)
else
    msg!.setString(BBjAdminEmailMessage.HTML, msghtml$)
endif
rem
to$="sua...@gmail.com"
cc$="jjag...@gmail.com"
from$="sua...@gmail.com"    
msg!.setString(BBjAdminEmailMessage.TO, to$)
msg!.setString(BBjAdminEmailMessage.FROM, from$)
msg!.setString(BBjAdminEmailMessage.CC, cc$)
rem
rem "ejemplo adjuntar archivo (solo disponible en BBj 20.20)
rem "------------------------
nombre$="nombre_archivo.pdf"
p_attachment1!=new BBjAdminEmailAttachment()
p_attachment1!.setFilename(nombre$)
p_attachment1!.setBytesFromFile(new java.io.File("c:/tmp/archivo.pdf"))
msg!.addAttachment(p_attachment1!)
rem
rem "ejemplo adjunto desde un contenido (solo disponible desde BBj 20.20)
rem "----------------------------------
p_attachment2!=new BBjAdminEmailAttachment()
p_attachment2!.setFilename("nombre_archivo.txt")
p_attachment2!.setBytes("el contenido del txt")
msg!.addAttachment(p_attachment2!)
rem
rem "envio del correo
rem "----------------
selectedEmailSvc!.sendMessage(msg!)
escape
rem
rem
msghtml:
msghtml$=$$
msghtml$=msghtml$+"<html>"
msghtml$=msghtml$+"  <head>"
msghtml$=msghtml$+"    <style type="+chr(34)+"text/css"+chr(34)+">"
msghtml$=msghtml$+"      <!--"
msghtml$=msghtml$+"        p { margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0 }"
msghtml$=msghtml$+"      -->"
msghtml$=msghtml$+"    </style>"
msghtml$=msghtml$+"  </head>"
msghtml$=msghtml$+"  <body>"
msghtml$=msghtml$+"<!-- #######  THIS IS A COMMENT - Visible only in the source editor #########-->"
msghtml$=msghtml$+"<h1>Envio de DTE Cliente</h1>"
msghtml$=msghtml$+"<h2>Emisor</h2>"
msghtml$=msghtml$+"<p style="+chr(34)+"font-size: 1.5em;"+chr(34)+">"+"razon social emisor"+"</p>"
msghtml$=msghtml$+"<p style="+chr(34)+"font-size: 1.5em;"+chr(34)+">RUT: "+"76.435.200-5"+"</p>"
msghtml$=msghtml$+"<h2>Receptor</h2>"
msghtml$=msghtml$+"<p style="+chr(34)+"font-size: 1.5em;"+chr(34)+">"+"razon social receptor"+"</p>"
msghtml$=msghtml$+"<p style="+chr(34)+"font-size: 1.5em;"+chr(34)+">RUT: "+"96.200.256-5"+"</p>"
msghtml$=msghtml$+"<h2>Detalle</h2>"
msghtml$=msghtml$+"<table border="+chr(34)+"1"+chr(34)+">"
msghtml$=msghtml$+"<tbody>"
msghtml$=msghtml$+"<tr>"
msghtml$=msghtml$+"<td>&nbsp;<strong>Tipo DTE</strong></td>"
msghtml$=msghtml$+"<td>&nbsp;<strong>Folio</strong></td>"
msghtml$=msghtml$+"<td>&nbsp;<strong>Fecha</strong></td>"
msghtml$=msghtml$+"<td>&nbsp;<strong>Monto</strong></td>"
msghtml$=msghtml$+"</tr>"
msghtml$=msghtml$+"<tr>"
msghtml$=msghtml$+"<td>&nbsp;"+"33"+"</td>"
msghtml$=msghtml$+"<td>&nbsp;"+"205022"+"</td>"
msghtml$=msghtml$+"<td>&nbsp;"+"27/12/2020"+"</td>"
msghtml$=msghtml$+"<td>&nbsp;$"+"102.000"+"</td>"
msghtml$=msghtml$+"</tr>"
msghtml$=msghtml$+"</tbody>"
msghtml$=msghtml$+"</table>"
msghtml$=msghtml$+"<p>Este correo adjunta Documentos Tributarios Electr&oacute;nicos (DTE) para el receptor electr&oacute;nico indicado. Por favor responda con un acuse de recibo (RespuestaDTE) conforme al modelo de intercambio de Factura Electr&oacute;nica del SII.</p>  </body>"
msghtml$=msghtml$+"</html>"
return
rem


--
Has recibido este mensaje porque estás suscrito al grupo "MundoBBx" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a mundobbx+u...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/mundobbx/23909689-a62e-4ab5-9362-a3bb86c9b05fn%40googlegroups.com.

Ricardo Paez V

unread,
Jul 15, 2022, 10:49:46 PM7/15/22
to MundoBBx
José

Consulta el ejemplo enviado .. para que versión del Bbj sirve ?

Slds

Ricardo

José Aguilar

unread,
Jul 15, 2022, 11:10:32 PM7/15/22
to MundoBBx
Hola Ricardo,

Entiendo que Email Service está disponible desde BBj 16.x o BBj 17.x
Sin embargo, la funcionalidad de Attachments presentaba problemas que reportamos a Basis.
Estos problemas se corrigieron en BBj 20.20

Saludos cordiales,

Administrador MundoBBx

César Suasnávar

unread,
Jul 16, 2022, 4:05:29 PM7/16/22
to mund...@googlegroups.com
Gracias José, lo probé en bbj 17 y no se adjuntan los archivos, lo probaré en alguna versión más reciente.

Saludos!

Has recibido este mensaje porque estás suscrito a un tema del grupo "MundoBBx" de Grupos de Google.
Para cancelar la suscripción a este tema, visita https://groups.google.com/d/topic/mundobbx/Yw5SAyuavBo/unsubscribe.
Para cancelar la suscripción a este grupo y a todos sus temas, envía un correo electrónico a mundobbx+u...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/mundobbx/CAH6vA8aejBbzwh_TMzp1owJu2KqyD9BfCF%3D01nBsGPTAtENPXQ%40mail.gmail.com.

Ricardo

unread,
Jul 16, 2022, 4:54:35 PM7/16/22
to mund...@googlegroups.com
QUe version de BBX me recomiendas buscar
De antemano muchas gracias



--

___________________________
Ricardo Linares Mendoza
Cel. 7434 5098
        6019 5464

José Aguilar

unread,
Jul 16, 2022, 5:00:55 PM7/16/22
to MundoBBx
Hola Ricardo Linares,

Siempre es recomendable utilizar la versión más reciente. Actualmente BBx/BBj está en la versión 22.02.
Siendo 16 de julio de 2022, puntualmente diría que la versión más estable es la 21.15, puesto que la versión 22.x implementó un nuevo mecanismo de licenciamiento (de BLM pasa a BLS) que aún está en proceso de mejora.

Saludos cordiales,

Administrador MundoBBx

Reply all
Reply to author
Forward
0 new messages