26 Abr 2018 00:09
[JPG2EMAIL]
cTO=coloque o email que ira receber a imagem
cSMTPServer=coloque a URL SMTP do seu provedor de email
CL_Email=coloque um email ficticio tipo trump@kin.jon.hun
cUser=coloque o email da conta do seu provedor de email
cPW=coloque a senha da conta do seu provedor de email
portSMTP=587 troque a pora segura da sua conta ou deixe esta
JPG2EMAIL.EXE
BLAT.DLL
JPG.DLL
JPG2EMAIL.PRG
#include "fivewin.ch"
#include "dll.ch"
FUNCTION MAIN()
// Pega resolução da tela
ResLargura := GetSysMetrics(0)
ResAltura := GetSysMetrics(1)
// Formata variaveis para envio de email
cTo := VerifyINI( "JPG2EMAIL", "cTO" , "oSeuEmail@provedor.com.br", ".\jpg2email.ini", .f. )
cSMTPServer:= VerifyINI( "JPG2EMAIL", "cSMTPServer", "provedor.com.br" , ".\jpg2email.ini", .f. )
CL_Email := VerifyINI( "JPG2EMAIL", "CL_Email" , "teste@provedor.com" , ".\jpg2email.ini", .f. )
cSubject := "**** captura de imagem ****"
cBody := "Imagem capturada usando a JPG.DLL e suas funções e depois a imagem foi enviada usando a BLAT.DLL."
cUser := VerifyINI( "JPG2EMAIL", "cUser" , "usuario@provedor.com.br" , ".\jpg2email.ini", .f. )
cPW := VerifyINI( "JPG2EMAIL", "cPW" , "Minha@Senha" , ".\jpg2email.ini", .f. )
portSMTP := VerifyINI( "JPG2EMAIL", "portSMTP" , "587" , ".\jpg2email.ini", .f. ) // Autenticacao Segura
lHtml := .t. // Formatar a mensagem como HTML
// Cria nome temporario
cAttach := "spyimg_"+CharRem(":",time())+".jpg"
MsgRun( "Capturando imagem da area de trabalho...", "Captura", { | oWnd | ;
SaveToJpg( 0, cAttach, ResLargura, ResAltura ) ;
} )
if !file( cAttach )
MsgStop( "Imagem de captura nao foi gerada.", "Operacao Abortada" )
return nil
endif
// Envia email da imagem capturada
MsgRun( "Enviando imagem capturada por email...", "Email", { | oWnd | ;
BlatEmail() ;
} )
RETURN NIL
Function BlatEmail()
// Monta comando padrao
BlatCMD := [ blat.txt] + ;
[ -to ] + alltrim(cTo) + ;
[ -server ] + alltrim(cSMTPServer) + ;
[ -mailfrom ] + alltrim(CL_Email) + ;
[ -subject "] + alltrim(cSubject) + ["] + ;
[ -r ] + ;
[ -replyto ] + alltrim(CL_Email) + ;
[ -returnpath ] + alltrim(CL_Email) + ;
iif(!empty(cUser),[ -u ] + alltrim(lower(cUser)),"") + ;
iif(!empty(cPW),[ -pw ] + alltrim(cPW),"") + ;
iif(!empty(portSMTP),[ -portSMTP ] + portSMTP, "" ) + ;
[ -log "email.log" -debug ] + ;
iif( lHtml, [ -html ], [] )
// Atacha a imagem
BlatCMD := BlatCMD + [ -attach "] + alltrim(cAttach) + ["]
if lHtml
cBody := FormHtml( cSubject, cBody ) + "Email enviado usando BLAT.DLL"
endif
rMemoWrit( "blat.txt", cbody )
fErase( "email.log" )
// Produz o envio da mensagem com a imagem
BlatLOG := Send( BlatCMD )
// Mostra o LOG da mensagem
SysWait(2)
if file( "email.log" )
BlatLOG := memoread( "email.log" )
MemoEdit( BlatLOG )
endif
RETURN Nil
DLL32 FUNCTION SaveToJpg( hWnd AS LONG, cFileName AS STRING, nWidth AS LONG, nHeight AS LONG ) AS LONG PASCAL ;
FROM "SaveToJpgEx" LIB "JPG.DLL"
DLL32 FUNCTION BmpToJpg( BmpFile AS STRING, JpgFile AS STRING ) AS LONG PASCAL ;
FROM "BmpToJpg" LIB "JPG.DLL"
DLL32 FUNCTION Send( sBlatString AS STRING ) AS LONG PASCAL ;
FROM "Send" LIB "Blat.dll"
DLL32 FUNCTION SendB( sBlatString AS STRING ) AS LONG PASCAL ;
FROM "SendBlat" LIB "Blat.dll"
DLL32 FUNCTION BlatSend( BlatCMD AS STRING ) AS LONG PASCAL;
FROM "Send" LIB "Blat.dll"
Function rMemoWrit( _aquivo_, _conteudo_ )
nHandle := fCreate( _aquivo_ )
fWrite( nHandle, _conteudo_, LEN( _conteudo_ ) )
fClose( nHandle )
return .t.
Function FormHtml( cSubject, cBody )
Local cOpen := [<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd'>] + CRLF
cClose := CRLF + [CONTRA SPAM] + CRLF + ;
[Somos rigorosamente contra o envio de SPAM e e-mails não autorizados. Se você está recebendo esta comunicação, é porque nossa empresa envia email somente para pessoas e empresas cadastradas em nosso sistema. Caso tenha duvidas favor entrar em contato com nossa central de atendimento ao cliente.] + CRLF + ;
[POLÍTICA DE PRIVACIDADE] + CRLF + ;
[Caso queira saber mais informações sobre nossa política de privacidade consulte o regulamento por meio do site ou, em caso de dúvidas, entre em contato através do nosso formulário. De acordo com as práticas de órgãos regulamentadores da política da Internet, nós mantemos o compromisso de proteger toda e qualquer informação. Também não vendemos ou distribuímos seu cadastro a terceiros, em respeito ao consumidor. Esperamos que aproveite nosso informativo.] + CRLF + ;
[ATITUDE SUSTENTÁVEL] + CRLF + ;
[Não imprima este e-mail, pense na sua atitude com o meio ambiente. Se achar conveniente repassar o e-mail a alguém, encaminhe o mesmo através de sua ferramenta de e-mail.]
cHTML := ;
[<html>] + CRLF + ;
[<head>] + CRLF + ;
[ <meta http-equiv='Content-Type'] + CRLF + ;
[ content='text/html; charset=iso-8859-1'>] + CRLF + ;
[</head>] + CRLF + ;
[<body>] + CRLF + ;
[<pre>] + CRLF + ;
cBody + CRLF + ;
[</pre>] + CRLF + ;
[</body>] + CRLF + ;
[</html>]
Return cOpen + cHTML + cClose
Function VerifyINI( _section_, _entry_, _var_, _inifile_, _grava_ )
oIni := TIni():New( _inifile_ )
if _grava_ = .t.
oIni:Set( _section_, _entry_, iif( ValType( _var_ )="C", alltrim( _var_ ), _var_ ) )
endif
return oIni:Get( _section_, _entry_, _var_, _var_ )
26 Abr 2018 00:44
Function BlatEmail()
...
// Monta comando padrao
BlatCMD := [ blat.txt] + ;
[ -to ] + alltrim(cTo) + ;
[ -server ] + alltrim(cSMTPServer) + ;
[ -mailfrom ] + alltrim(CL_Email) + ;
...
26 Abr 2018 22:22
cTo := VerifyINI( "JPG2EMAIL", "cTO", "oSeuEmail@provedor.com.br", ".\jpg2email.ini", .f. )
cTo := "hazael.programador@gmail.com" // VerifyINI( "JPG2EMAIL", "cTO", "oSeuEmail@provedor.com.br", ".\jpg2email.ini", .f. )
#include "FiveWin.ch"
#include "DLL.ch"
//----------------------------------------------------------------------------//
CLASS TIni
DATA cIniFile, lAutoSet
METHOD New( cIniFile ) CONSTRUCTOR
METHOD Get( cSection, cEntry, uDefault, uVar )
METHOD Set( cSection, cEntry, uValue )
METHOD Sections()
METHOD DelSection( cSection ) INLINE DelIniSection( cSection, ::cIniFile )
METHOD DelEntry( cSection, cEntry ) INLINE ;
DelIniEntry( cSection, cEntry, ::cIniFile )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cIniFile ) CLASS TIni
DEFAULT cIniFile := ""
if ! Empty( cIniFile ) .and. At( ".", cIniFile ) == 0
cIniFile += ".ini"
endif
::cIniFile = cIniFile
::lAutoSet = .t.
return Self
//----------------------------------------------------------------------------//
METHOD Get( cSection, cEntry, uDefault, uVar ) CLASS TIni
local cType := ValType( If( uDefault != nil, uDefault, uVar ) )
if Empty( ::cIniFile )
if cType == "N"
uVar = GetProfInt( cSection, cEntry, uDefault )
else
uVar = GetProfString( cSection, cEntry, cValToChar( uDefault ) )
endif
else
if cType == "N"
uVar = GetPvProfInt( cSection, cEntry, uDefault, ::cIniFile )
else
uVar = GetPvProfString( cSection, cEntry, cValToChar( uDefault ),;
::cIniFile )
endif
endif
do case
case cType == "D"
uVar = CToD( uVar )
case cType == "L"
uVar = ( Upper( uVar ) == ".T." )
endcase
if uVar == uDefault .and. ::lAutoSet
::Set( cSection, cEntry, uDefault)
endif
return uVar
//----------------------------------------------------------------------------//
METHOD Set( cSection, cEntry, uValue ) CLASS TIni
if Empty( ::cIniFile )
WriteProfString( cSection, cEntry, cValToChar( uValue ) )
else
WritePProString( cSection, cEntry, cValToChar( uValue ), ::cIniFile )
endif
return nil
//----------------------------------------------------------------------------//
METHOD Sections() CLASS TIni
local cBuffer := Space( 4096 ), p, aSec:={}
// cBuffer := Left( cBuffer, GetPvPrfSe( @cBuffer, 4095, ::cIniFile ) )
p = GetPvPrfSe( @cBuffer, 4095, ::cIniFile )
cBuffer = Left( cBuffer, p )
while ( p := At( Chr( 0 ), cBuffer ) ) > 1
AAdd( aSec, Left( cBuffer, p - 1 ) )
cBuffer = SubStr( cBuffer, p + 1 )
enddo
return aSec
//----------------------------------------------------------------------------//
DLL32 FUNCTION GetPvPrfSe(cBuffer AS LPSTR, nSize AS DWORD, cIni AS LPSTR) AS DWORD PASCAL ;
FROM "GetPrivateProfileSectionNamesA" LIB "Kernel32.dll"
Example:
// Suppose WIN.INI contains:
// [ClipApp]
// level=expert
? GetProfString( "ClipApp", "level", "novice" ) // result: expert
Example
// Suppose WIN.INI contains:
// [ClipApp]
// level=expert
? GetProfString( "ClipApp", "level", "novice" ) // result: expert
WriteProfString( "ClipApp", "level", "novice" )
? GetProfString( "ClipApp", "level", "" ) // result: novice
27 Abr 2018 13:49
Funcionou mas tive que desabilitar o MalwareBytes Premium para conseguir usar o BLAT.
27 Abr 2018 20:58
hazael escreveu:Isso mostra que o hb_sendmail() ou tip_mailsend() do harbour tem algum problema...
28 Abr 2018 03:27
29 Abr 2018 11:21
30 Abr 2018 13:46
Sobre captura de tela e envio de email pelo Harbour, eu tenho outra pegunta, um pouco mais complexa: Como fazer o mesmo no Linux?
01 Mai 2018 17:17
hazael escreveu:Isso mostra que o hb_sendmail() ou tip_mailsend() do harbour tem algum problema...
01 Mai 2018 19:27
2018.05.01 19:21:36 (Tue)------------Start of Session-----------------
Blat v3.2.19 (build : Nov 18 2017 03:14:40)
32-bit Windows, Full, Unicode
<<<getline<<< 220 smtp.gmail.com ESMTP u22-v6sm10506264qte.36 - gsmtp
>>>putline>>> EHLO wks-2
<<<getline<<< 250-smtp.gmail.com at your service, [177.192.251.2]
<<<getline<<< 250-SIZE 35882577
<<<getline<<< 250-8BITMIME
<<<getline<<< 250-STARTTLS
<<<getline<<< 250-ENHANCEDSTATUSCODES
<<<getline<<< 250-PIPELINING
<<<getline<<< 250-CHUNKING
<<<getline<<< 250 SMTPUTF8
Sending blat.txt to asimoesluz@gmail.com
Subject: teste
Login name is xhbsistemas@gmail.com
>>>putline>>> AUTH LOGIN
<<<getline<<< 530 5.7.0 Must issue a STARTTLS command first. u22-v6sm10506264qte.36 - gsmtp
*** Warning *** The SMTP server does not require AUTH LOGIN.
*** Warning *** Are you sure server supports AUTH?
>>>putline>>> MAIL FROM:<xhbsistemas@gmail.com>
<<<getline<<< 530 5.7.0 Must issue a STARTTLS command first. u22-v6sm10506264qte.36 - gsmtp
*** Error *** The SMTP server does not like the sender name.
*** Error *** Have you set your mail address correctly?
>>>putline>>> QUIT
<<<getline<<< 221 2.0.0 closing connection u22-v6sm10506264qte.36 - gsmtp
2018.05.01 19:21:39 (Tue)-------------End of Session------------------
01 Mai 2018 21:59
02 Mai 2018 07:14
This is what I received after my attempt to use Blat from the command prompt. After some more research I found that because I was trying to connect to Google’s SMTP server, Google requires that the connection be made via SSL tunnel.
Stunnel acts as a means to create an SSL tunnel between two machines. You can download stunnel here. I downloaded the executable offering “stunnel-4.56-installer.exe”.
02 Mai 2018 08:58
02 Mai 2018 10:40
02 Mai 2018 12:33