Árvore de páginas

Versões comparadas

Chave

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

...

Bloco de código
languagejs
firstline1
titleJavascript: sendWithAttachment
linenumberstrue
collapsetrue
var controller;

controller = function ($rootScope, $scope, MailService) {

	this.onSelectFiles = function(selectedFiles) {
		if (angular.isDefined(selectedFiles)) {
			this.sendEmail(selectedFiles);
		}
	};

	this.sendEmail = funcion(files) {
		MailService.sendWithAttachment({
			reply: "[email protected]",
			alias: "[email protected]",
		    to: "[email protected]",
			cc: "[email protected]",
			subject: "Datasul Mail Service",
			content: "Hello from the other side !"
		}, files, 
		function(result, mail) {
			console.info(result, mail);
		}, function(progress, evt, mail) {
			console.warn(progress, evt, mail);
		}, function(result, status, headers, config, email) {
			console.error(result, status, headers, config, email);
		});
    };
};

controller.$inject = ['$rootScope', '$scope', 'MailService'];

------------------------------------------------------------------------------------
<html>
<head></head>
<body>
	
	<label class="btn btn-default pull-right"
    	   role="button"
           for="file-input">
		Selecione os arquivos...
	</label>
	
	<span class="file-text"></span>
    
	<input id="file-input"
           type="file"
           style="position:fixed;top:-999px;"
           ngf-select
           ngf-change="controller.onSelectFiles($files);"
           ngf-multiple="true"
           ngf-allow-dir="false"/>

</body>
</html>

 

 

 

Bloco de código
languagejava
themeEclipse
firstline1
titleProgress: sendWithAttachment
linenumberstrue
collapsetrue
{utp\utapi019.i2}

RUN utp/utapi019.p PERSISTENT SET h-utapi019. 

create tt-envio2.
assign tt-envio2.versao-integracao = 1
       tt-envio2.exchange    = NO
       tt-envio2.servidor    = 'smtp.totvs.com.br'
       tt-envio2.porta       = 587
       tt-envio2.destino     = "[email protected]"
       tt-envio2.remetente   = "[email protected]"
       tt-envio2.assunto     = "Datasul Mail Service"
       tt-envio2.mensagem    = "Hello from the other side !"
       tt-envio2.importancia = 2
       tt-envio2.log-enviada = NO
       tt-envio2.log-lida    = NO
       tt-envio2.acomp       = NO
       tt-envio2.formato     = 'html'.

CREATE tt-mensagem.
ASSIGN tt-mensagem.mensagem = tt-envio2.mensagem.

caso não sejam informados os campos da tabela tt-paramEmail2, serão utilizados as configurações dos parâmetros de email foundation */
CREATE tt-paramEmail2.
ASSIGN tt-paramEmail2.caminhoEmail = 1
       tt-paramEmail2.mailUser = '<user_email>'
       tt-paramEmail2.mailPass = '<senha_email>'
       tt-paramEmail2.TLS      = NO
       tt-paramEmail2.SSL      = NO
       tt-paramEmail2.DEBUG    = YES. 


CREATE ttAttachment.
ASSIGN ttAttachment.fileName = '<nome_arquivo>'.

COPY-LOB FROM FILE ttAttachment.FILENAME TO ttAttachment.fileContent NO-CONVERT NO-ERROR.  /* caso esteja disponível apenas o binário do arquivo, basta atribui-lo ao campo ttAttachment.fileContent */

RUN pi-execute4 IN h-utapi019 (INPUT  Table tt-envio2,
    INPUT  Table tt-mensagem,
    INPUT  Table tt-paramEmail2,
    INPUT  TABLE ttAttachment,
    OUTPUT Table tt-erros).
if  return-value = "NOK" then do:
    for each tt-erros:
        disp tt-erros with 1 column width 300.
    end.                               
end.