Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
languagejava
themeEclipse
firstline1
titleProgress: sendSimple
linenumberstrue
collapsetrue
DEFINE VARIABLE h_mail AS HANDLE NO-UNDO.

IF NOT VALID-HANDLE(h_mail) THEN DO: 
	RUN utp/ut-mail-api.p PERSISTENT SET h_mail.
END.

DEFINE VARIABLE c_to                    AS CHARACTER NO-UNDO EXTENT.
DEFINE VARIABLE c_cc                    AS CHARACTER NO-UNDO EXTENT.
DEFINE VARIABLE c_bcc                   AS CHARACTER NO-UNDO EXTENT.
DEFINE VARIABLE c_subject               AS CHARACTER NO-UNDO INITIAL 'Teste API Progress - Datasul Mail Service':U.
DEFINE VARIABLE c_from                  AS CHARACTER NO-UNDO INITIAL '[email protected]':U.
DEFINE VARIABLE c_from_name             AS CHARACTER NO-UNDO INITIAL 'Datasul Mail Service':U.
DEFINE VARIABLE lc_content_mail         AS LONGCHAR  NO-UNDO.
DEFINE VARIABLE l_html                  AS LOGICAL   NO-UNDO INITIAL TRUE.
    
DEFINE VARIABLE c_read_notification     AS LOGICAL   NO-UNDO INITIAL TRUE.
DEFINE VARIABLE i_delivery_notification AS LOGICAL   NO-UNDO INITIAL TRUE.
DEFINE VARIABLE i_return_type           AS LOGICAL   NO-UNDO INITIAL TRUE.

ASSIGN lc_content_mail = 'Teste de envio de e-mail pelo PROGRESS :D':U.

EXTENT (c_to) = 1.                                       
ASSIGN c_to[1] = '[email protected]':U.

RUN sendSimple IN h_mail(
    INPUT c_to,
    INPUT c_cc,
    INPUT c_bcc,
    INPUT c_subject,
    INPUT c_from,
    INPUT c_from_name,
    INPUT lc_content_mail,
    INPUT l_html,
    OUTPUT mptr_response,
    OUTPUT i_response_code,
	OUTPUT c_response_status
).

IF VALID-HANDLE(h_mail) THEN DO: 
	DELETE PROCEDURE h_mail.
END.
Bloco de código
languagejava
themeEclipse
firstline1
titleProgress: sendWithAttachment
linenumberstrue
collapsetrue
{utp/ut-mail-api.i}

DEFINE VARIABLE h_mail AS HANDLE NO-UNDO.

IF NOT VALID-HANDLE(h_mail) THEN DO: 
	RUN utp/ut-mail-api.p PERSISTENT SET h_mail.
END.

DEFINE VARIABLE c_to                    AS CHARACTER NO-UNDO EXTENT.
DEFINE VARIABLE c_cc                    AS CHARACTER NO-UNDO EXTENT.
DEFINE VARIABLE c_bcc                   AS CHARACTER NO-UNDO EXTENT.
DEFINE VARIABLE c_subject               AS CHARACTER NO-UNDO INITIAL 'Teste API Progress - Datasul Mail Service':U.
DEFINE VARIABLE c_from                  AS CHARACTER NO-UNDO INITIAL '[email protected]':U.
DEFINE VARIABLE c_from_name             AS CHARACTER NO-UNDO INITIAL 'Datasul Mail Service':U.
DEFINE VARIABLE lc_content_mail         AS LONGCHAR  NO-UNDO.
DEFINE VARIABLE l_html                  AS LOGICAL   NO-UNDO INITIAL TRUE.
    
DEFINE VARIABLE c_read_notification     AS LOGICAL   NO-UNDO INITIAL TRUE.
DEFINE VARIABLE i_delivery_notification AS LOGICAL   NO-UNDO INITIAL TRUE.
DEFINE VARIABLE i_return_type                AS LOGICAL   NO-UNDO INITIAL TRUE.

ASSIGN lc_content_mail = 'Teste de envio de e-mail pelo PROGRESS :D':U.

EXTENT (c_to) = 1.                                       
ASSIGN c_to[1] = '[email protected]':U.

CREATE ttAttachment.
ASSIGN ttAttachment.fileName = '<NOME ANEXO 1>'.
    
COPY-LOB FROM FILE '<CAMINHO ANEXO 1>' 
	TO ttAttachment.fileContent NO-CONVERT NO-ERROR.

CREATE ttAttachment.
ASSIGN ttAttachment.fileName = '<NOME ANEXO 2>'.
    
COPY-LOB FROM FILE '<CAMINHO ANEXO 2>' 
	TO ttAttachment.fileContent NO-CONVERT NO-ERROR.

RUN sendWithAttachment IN h_mail(
    INPUT c_to,
    INPUT c_cc,
    INPUT c_bcc,
    INPUT c_subject,
    INPUT c_from,
    INPUT c_from_name,
    INPUT lc_content_mail,
    INPUT l_html,
	INPUT TABLE ttAttachment,
	OUTPUT mptr_response,
    OUTPUT i_response_code,
	OUTPUT c_response_status
).

IF VALID-HANDLE(h_mail) THEN DO: 
	DELETE PROCEDURE h_mail.
END.
Bloco de código
languagejava
themeEclipse
firstline1
titleProgress: sendWithAttachment
linenumberstrue
collapsetrue
{utp/ut-mail-api.i}

DEFINE VARIABLE h_mail AS HANDLE NO-UNDO.

IF NOT VALID-HANDLE(h_mail) THEN DO: 
	RUN utp/ut-mail-api.p PERSISTENT SET h_mail.
END.

DEFINE VARIABLE c_to                    AS CHARACTER NO-UNDO EXTENT.
DEFINE VARIABLE c_cc                    AS CHARACTER NO-UNDO EXTENT.
DEFINE VARIABLE c_bcc                   AS CHARACTER NO-UNDO EXTENT.
DEFINE VARIABLE c_subject               AS CHARACTER NO-UNDO INITIAL 'Teste API Progress - Datasul Mail Service':U.
DEFINE VARIABLE c_from                  AS CHARACTER NO-UNDO INITIAL '[email protected]':U.
DEFINE VARIABLE c_from_name             AS CHARACTER NO-UNDO INITIAL 'Datasul Mail Service':U.
DEFINE VARIABLE lc_content_mail         AS LONGCHAR  NO-UNDO.
DEFINE VARIABLE l_html                  AS LOGICAL   NO-UNDO INITIAL TRUE.
    
DEFINE VARIABLE c_read_notification     AS LOGICAL   NO-UNDO INITIAL TRUE.
DEFINE VARIABLE i_delivery_notification AS LOGICAL   NO-UNDO INITIAL TRUE.
DEFINE VARIABLE i_return_type           AS LOGICAL   NO-UNDO INITIAL TRUE.
    
ASSIGN lc_content_mail = 'Teste de envio de e-mail pelo PROGRESS :D':U.

EXTENT (c_to) = 1.                                       
ASSIGN c_to[1] = '[email protected]':U.

CREATE ttAttachment.
ASSIGN ttAttachment.fileName = '<NOME ANEXO 1>'.
    
COPY-LOB FROM FILE '<CAMINHO ANEXO 1>' 
	TO ttAttachment.fileContent NO-CONVERT NO-ERROR.

RUN sendEmail IN h_mail(
    INPUT c_to,
    INPUT c_cc,
    INPUT c_bcc,
    INPUT c_subject,
    INPUT c_from,
    INPUT c_from_name,
    INPUT lc_content_mail,
    INPUT l_html,
	INPUT '[email protected]',
    INPUT 1,
	INPUT 1,
	INPUT 1,
    INPUT TABLE ttAttachment,
	OUTPUT mptr_response,
    OUTPUT i_response_code,
	OUTPUT c_response_status
).

IF VALID-HANDLE(h_mail) THEN DO: 
	DELETE PROCEDURE h_mail.
END.
Bloco de código
languagejava
themeEclipse
firstline1
titleProgress: Report + Mail
linenumberstrue
collapsetrue
{utp/ut-mail-api.i}
{utp/ut-report-api.i}

DEFINE VARIABLE i_ocorrencia      AS INTEGER   NO-UNDO INITIAL 101552.
DEFINE VARIABLE c_report          AS CHARACTER NO-UNDO INITIAL 'crm/rel_ratec_tecnico/':U.
DEFINE VARIABLE c_program         AS CHARACTER NO-UNDO INITIAL 'program=/report/crm/crm0001':U.
DEFINE VARIABLE c_format          AS CHARACTER NO-UNDO INITIAL 'html':U.
DEFINE VARIABLE c_dialect         AS CHARACTER NO-UNDO INITIAL 'pt':U.
DEFINE VARIABLE l_publish         AS LOGICAL   NO-UNDO INITIAL TRUE.
DEFINE VARIABLE l_download        AS LOGICAL   NO-UNDO INITIAL TRUE.

DEFINE VARIABLE h_api             AS HANDLE    NO-UNDO.
DEFINE VARIABLE h_mail            AS HANDLE    NO-UNDO.
DEFINE VARIABLE h_report          AS HANDLE    NO-UNDO.

DEFINE VARIABLE lc_content        AS LONGCHAR  NO-UNDO.
DEFINE VARIABLE c_query_params    AS CHARACTER NO-UNDO.

DEFINE VARIABLE i_response_code   AS INTEGER   NO-UNDO.
DEFINE VARIABLE c_response_status AS CHARACTER NO-UNDO.
DEFINE VARIABLE mptr_response     AS MEMPTR    NO-UNDO.

/* ************************************************** */
/* *** Busca os dados para impressão do relatório *** */
/* ************************************************** */

ASSIGN c_query_params = '&num_id_ocor=':U + STRING(i_ocorrencia).

IF NOT VALID-HANDLE(h_api) THEN DO: 
    RUN report/crm/crm0001.p PERSISTENT SET h_api.
END.

RUN getReportDataRPW IN h_api(INPUT TABLE ttReport, INPUT i_ocorrencia, OUTPUT lc_content, OUTPUT TABLE RowErrors).

IF VALID-HANDLE(h_api) THEN DO: 
    DELETE PROCEDURE h_api.
END.

/* ************************************************** */
/* *** Realiza a chamada para o Datasul Report    *** */
/* ************************************************** */

IF NOT VALID-HANDLE(h_report) THEN DO: 
    RUN utp/ut-report-api.p PERSISTENT SET h_report.
END.

RUN print IN h_report (
    INPUT c_report, 
    INPUT c_program, 
    INPUT c_format, 
    INPUT c_dialect,
    INPUT l_publish, 
    INPUT l_download, 
    INPUT lc_content, 
    INPUT c_query_params,
    OUTPUT mptr_response,
    OUTPUT i_response_code,
    OUTPUT c_response_status
).

IF VALID-HANDLE(h_report) THEN DO: 
    DELETE PROCEDURE h_report.
END.

IF i_response_code EQ 200 AND mptr_response NE ? THEN DO:

    /* ************************************************** */
    /* *** Agora enviamos por e-mail o HTML gerado    *** */
    /* ************************************************** */
    
    IF NOT VALID-HANDLE(h_mail) THEN DO: 
        RUN utp/ut-mail-api.p PERSISTENT SET h_mail.
    END.
    
    DEFINE VARIABLE c_to                    AS CHARACTER NO-UNDO EXTENT.
    DEFINE VARIABLE c_cc                   END.
 AS CHARACTER NO-UNDO EXTENT.
    DEFINE VARIABLE c_bccto                    AS CHARACTER NO-UNDO EXTENT.
    DEFINE VARIABLE c_subjectcc               AS CHARACTER NO-UNDO INITIAL 'Teste APIAS ProgressCHARACTER NO- Datasul Mail Service':UUNDO EXTENT.
    DEFINE VARIABLE c_frombcc                   AS CHARACTER NO-UNDO INITIAL '[email protected]':U.EXTENT.
    DEFINE VARIABLE c_from_namesubject               AS CHARACTER NO-UNDO INITIAL 'Datasul Mail Service':U.
    DEFINE VARIABLE lc_content_mail         AS LONGCHAR  NO-UNDOTeste API Progress - Datasul Mail Service':U.
    DEFINE VARIABLE lc_htmlfrom                  AS LOGICAL  CHARACTER NO-UNDO INITIAL TRUE'[email protected]':U.
    
    DEFINE VARIABLE c_read_notificationfrom_name           AS LOGICAL AS CHARACTER NO-UNDO INITIAL TRUE 'Datasul Mail Service':U.
    DEFINE VARIABLE ilc_delivery_notificationcontent_mail         AS LOGICAL LONGCHAR  NO-UNDO INITIAL TRUE.
    DEFINE VARIABLE i_return_type l_html                  AS LOGICAL   NO-UNDO INITIAL TRUE.
    
    COPY-LOB FROM mptr_response TO lc_content_mail NO-CONVERT NO-ERROR.

    EXTENT (c_to) = 1.                                   
    
    ASSIGN c_to[1] = '[email protected]':U.   
    
    CREATE ttAttachment.
    ASSIGN ttAttachment.fileName = '<NOME ANEXO 1>'.
    
    COPY-LOB FROM FILE '<CAMINHO ANEXO 1>' 
        TO ttAttachment.fileContent NO-CONVERT NO-ERROR.

    RUN sendEmail IN h_mail(
        INPUT c_to,
        INPUT c_cc,
        INPUT c_bcc,
        INPUT c_subject,
        INPUT c_from,
        INPUT c_from_name,
        INPUT lc_content_mail,
        INPUT l_html,
        INPUT '[email protected]',
        INPUT 1, /* Notificar: -1. Nunca 1. Sucesso 2. Falha 3. INPUT c_from_name,Atraso */
        INPUT lc_content_mail1,
 /* Tipo de Retorno: 1. Completo 2. Cabeçalho INPUT l_html,
        */
		INPUT '[email protected]',
        INPUT 1,
1, /* Prioridade: 1. Alta 3. Normal 5. Baixa          INPUT 1,
		INPUT 1, */
		INPUT TABLE ttAttachment,
        OUTPUT mptr_response,
        OUTPUT i_response_code,
        OUTPUT c_response_status
    ).
    
    IF VALID-HANDLE(h_mail) THEN DO: 
        DELETE PROCEDURE h_mail.
    END.

END.