Jump to content
Fivewin Brasil

exe para enviar e-mails


mkyx

Recommended Posts

Bom dia, alguém tem um pequeno programa que possa ser executado fora do programa principal, para enviar qualquer tipo de e-mail com segurança?

Porque a rotina da flexdocs, só dá pau, constantemente, o gmail, o hotmail, fica bloqueando, todos os clientes ficam reclamando que o email, não está indo.

O ideal seria, se tivesse um pequeno exe, que fosse executado através de um arquivo .bat

Obrigado.

 

Link to comment
Share on other sites

Amiguinhos,

Eu uso o blat assim:

	    cErrorFile := "NFWHErr.log"
    REDEFINE BUTTON oBtn1 ID 1 OF oDlg ;
                 ACTION ( iif( file( "develop.dev" ), fun(), Blat( "Cliente: " + CL_NOME,;
                                "seudominio.com.br",;
                                "nfe@seudominio.com.br",;
                                "nfe@seudominio.com.br",;
                                "***** Mensagem do Sistema de Erros 5Volution *****",;
                                "nfe@seudominio.com.br",;
                                "s3nh@s3cr3t@",;
                                cErrorFile ) ) )
	

Funcao chamada:

	/*
 *****************************************************************************
 *    FUNCAO: Faz uso do BLAT para enviar emails diretamente pela internet   *
 *****************************************************************************
 */
function blat( cbody ,;
               cserver ,;
               cto ,;
               cf ,;
               csubject ,;
               cu ,;
               cpw ,;
               cattach, lHtml, portSMTP, lSendBack )
     /* BLAT.EXE  blat.txt
      *           -server mail.seudominio.com.br
      *           -to emaildocliente@hotmail.com.br
      *           -f fabricapet@seudominio.com.br
      *           -subject "**** confirmacao de pedido ****"
      *           -u fabricapet@seudominio.com.br
      *           -pw s3nh@s3cr3t@
      *           -log "email.log"
      *           -debug
      *           -attach "EC030017.RTF"
      */
     lHtml := .t.
     BlatCMD := [ blat.txt] + ;
                [ -to ]       + alltrim(cto) + ;
                [ -server ]   + alltrim(cserver) + ;
                iif(!empty(cu),[ -f ] + alltrim(lower(cu)),"") + ;
                iif(empty(CL_Email), "", [ -mailfrom ] + alltrim(lower(CL_Email)) ) + ;
                [ -subject "] + alltrim(csubject) + ["] + ;
                [ -r ]        + ;
                iif(empty(CL_Email), "", [ -replyto ] + alltrim(lower(iif(lSendBack,CL_Email,cu))) ) + ;
                iif(empty(CL_Email), "", [ -returnpath ] + alltrim(lower(CL_Email)) ) + ;
                iif(!empty(cu),[ -u ] + alltrim(lower(cu)),"") + ;
                iif(!empty(cpw),[ -pw ] + alltrim(cpw),"") + ;
                iif(!empty(portSMTP),[ -portSMTP ] + portSMTP, "" ) + ;
                [ -log "email.log" -debug ] + ;
                iif( lHtml, [ -html ], [] )
     if empty( cAttach )
     else
        if ValType( cAttach ) == "A"
           BlatCMD := BlatCMD + [ -attach "] + alltrim(cAttach[ 1 ]) + ["]
           For nEle = 2 To Len( cAttach )
               BlatCMD := BlatCMD + [,"] + alltrim(cAttach[ nEle ]) + ["]
           Next
        else
           BlatCMD := BlatCMD + [ -attach "] + alltrim(cAttach) + ["]
        endif
     endif
     if lHtml
        cBody := FormHtml( cSubject, cBody )
     endif
     fErase( "blat.bat" )
     rMemoWrit( "blat.txt", cbody + "Enviado via BLAT.EXE" )
     rMemoWrit( "blat.bat", BlatCMD )
     fErase( "email.log" )
     //
     cMacro := "BLAT.EXE " + BlatCMD
     rMemoWrit( "blat.bat", cMacro )
     MsgRun("Aguarde o termino do processo","Envio de Email...",{||WaitRun( cMacro, 0 )})
     SysWait(2)
     if file( "email.log" )
        BlatLOG := memoread( "email.log" )
        if "ERROR" $ Upper(BlatLOG)
           //MemoEdit( BlatLOG )
           return .f.
        endif
        if "535" $ Upper(BlatLOG)
           MsgStop( "Erro: Authentication Failed" + CRLF + CRLF + "Senha/Login de autenticacao com erro." )
           return .f.
        endif
        //if "550" $ Upper(BlatLOG)
        //   MsgStop( "Erro: User Unknown" + CRLF + CRLF + "Usuario destino desconhecido." )
        //   return .f.
        //endif
     endif
     RETURN .T.
	FUNCTION FUN()
	     MsgStop( "nao envia casa esteja na maquina de desenvolvimento" )
	     return .t.

Download do Blat

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...