Enviar correo electrónico desde Invantive UniversalSQL usando SMTP

Usando Invantive UniversalSQL puedes enviar correos electrónicos siguiendo estos pasos:

  • Configura los ajustes SMTP.
  • Envía el correo usando un insert en smtp@mail.

La configuración de los ajustes SMTP se puede hacer usando sentencias SQL set por separado o mediante un bloque PSQL como el siguiente. La lista completa de ajustes disponibles está documentada en línea:

begin
  set smtp-host-address@mail "smtp.office365.com";
  set smtp-minimum-deliver-duration-ms@mail 5000;
  set smtp-user-name@mail "john.doe@acme.com";
  set smtp-password@mail "verysecret";
  set [mail-from-name]@mail "ACME System";
  set [mail-from-email]@mail "mailsender@acme.com";
  set [mail-body-html]@mail false;
  set smtp-enable-ssl@mail true;
  set mail-priority@mail -1;
  set smtp-minimum-deliver-duration-ms@mail 1000;
end;

El envío real de un correo electrónico simple se realiza con:

    insert into smtp@mail
    ( toEmail
    , ccEmail
    , bccEmail
    , subject
    , body
    --, attachmentContents
    --, attachmentName
    --, attachmentMimeType
    )
    select 'johnsmother@acme.com'
           toEmail
    ,      cast(null as varchar2)
           ccEmail
    ,      cast(null as varchar2)
           bccEmail
    ,      'Hi hi'
           subject
    ,      'hi,'
           || chr(13) || 'How are you?'
           body

Agregando lo siguiente al final del SQL anterior, también puedes incluir un archivo adjunto:

... código original
,      rfe.file_contents
       attachmentContents
,      basename(fle.file_path)
       attachmentName
,      cast(null as varchar2)
       attachmentMimeType
from   files('c:\temp', 'spreadsheet.xlsx', false)@os fle
join   read_file(fle.file_path)@os rfe
1 me gusta

Een bericht is samengevoegd naar een bestaand topic: How to remove delivery notifications from smtp@mail with 22.0.330