Jump to content
Fivewin Brasil

Outlook Express/Windows Live Mail


kapiaba

Recommended Posts


#Include "FiveWin.ch"
#Include "Mail.ch"

FUNCTION Main()

LOCAL cErrorLog

cErrorLog := "C:\FWH1306\SAMPLES\ERROR.Log"

SendEmail( cErrorLog )

RETURN NIL

FUNCTION SendEmail( cErrorLog )

TRY
oCfg := CREATEOBJECT( "CDO.Configuration" )

WITH OBJECT oCfg:Fields

:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := "smtp.pleno.com.br"
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := 587 // Porta do Servidor
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := .T.
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := .F.
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := "joao@pleno.com.br" //<seu_email>
:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := "2426275" // <sua_senha>
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") :Value = 30
:Update()

END WITH

CATCH oError

MsgInfo( "Não Foi possível Enviar o e-Mail!" +CRLF+ ;
"Error: " + Transform(oError:GenCode, nil) + ";" +CRLF+ ;
"SubC: " + Transform(oError:SubCode, nil) + ";" +CRLF+ ;
"OSCode: " + Transform(oError:OsCode, nil) + ";" +CRLF+ ;
"SubSystem: " + Transform(oError:SubSystem, nil) + ";" +CRLF+ ;
"Mensaje: " + oError:Description, "CDO.Configuração" )

END

//aAttach := SetErrorPath() + SetErrorFileName()
aAttach := "C:\FWH1306\SAMPLES\ERROR.Log"

TRY
oMsg := CREATEOBJECT ( "CDO.Message" )

WITH OBJECT oMsg

:Configuration = oCfg

//:From = CHR(34) + "<nome_empresa_cliente>" + CHR(34)+ <email_seu_envio>
:From = CHR(34) + "TORBAL IND E COM DE ESCAPAMENTOS LTDA" + CHR(34)+ "joao@pleno.com.br"

//:To = <para_qual_email_enviar_o_LOG>
:To = "joao@pleno.com.br" //<para_qual_email_enviar_o_LOG>

:Subject = "Envio Automático do Erro"

:MDNRequested = .F.

:TextBody = cErrorLog

:AddAttachment(aAttach)

:Send()

END WITH

MsgInfo("Mensagem Enviada com Sucesso!","Atençao")

CATCH oError

MsgInfo( "Não Foi possível Enviar o e-Mail!" +CRLF+ ;
"Error: " + Transform(oError:GenCode, nil) + ";" +CRLF+ ;
"SubC: " + Transform(oError:SubCode, nil) + ";" +CRLF+ ;
"OSCode: " + Transform(oError:OsCode, nil) + ";" +CRLF+ ;
"SubSystem: " + Transform(oError:SubSystem, nil) + ";" +CRLF+ ;
"Mensaje: " + oError:Description, "CDO.Message" )
END TRY

RETURN NIL


Link to comment
Share on other sites

Eu uso uma solução que funciona bem, só não funciona se o usuário bloquear pelo firewall o envio de msgs pelo programa, mas tem avisos de alerta sobre isso.

Sempre que o programa abre, verifica se tem error.log

IF file("ERROR.LOG")
IF SendMail(oWmaster)

.....

//---------------

//------------------------------------------------------------
function SendMail(oWmaster)


local oOutMail, oIP, mailport := 587, mailauth := .T., usuario:="nome@meudominio", senha:="asenha"
local errorlog := memoread("error.log")

WsaStartUp()
oIP :=GETHOSTBYNAME("mail2.meudominio.com.br")
//msginfo(oIP,"oIP")
If oIP = "0.0.0.0"
DelLog:=.f.
WsaCleanUp()
return .f.
End

mailport := 587

oWmaster:SetMsg( "Sending Internet email..." )
oOutMail:=TSmtpt():New(GETHOSTBYNAME("mail2.meudominio.com.br"))
oOutMail := TSmtpt():New(GETHOSTBYNAME("mail2.meudominio.com.br"), mailport, mailauth , usuario, senha)

if Log_SMTP
ooutMail:oSocket:lDebug := .T.
ooutMail:oSocket:cLogFile := "smtp.log"
end

oOutMail:bConnecting = { || oWmaster:SetMsg( "Connecting" ) }
oOutMail:bConnected = { || oWmaster:SetMsg( "Connected" ) }
oOutMail:bDone = { || oWmaster:SetMsg( "Message sent successfully" ) , oOutMail:end(), WsaCleanUp() }
oOutMail:SendMail( "nome@meudominio",; // From
{ "praonde@meudominio" },; // To
Ver+CRLF+"From:"+vemail+CRLF+s_ua+CRLF+vrodape1+CRLF+vrodape2+CRLF+vwww+CRLF+"Hd:"+subs(alltrim(str(nSerialHD())),1,8)+"."+subs(alltrim(str(nSerialHD())),9,3)+CRLF+logo+CRLF+ ":=:=:=:=:=:"+CRLF+errorlog,; // Msg Text
top_rel,; // Subject
{} ,"t","") // attached files




return .t.

//--------------------

no meu dominio criei usuario de e-mail somente para isso. autentica nele para enviar

conta criada unicamente para isso

então recebo a toda hora o error.log e a identificação do usuário

serve muito bem prá pegar piratas também.

[]´s

Link to comment
Share on other sites

Rogério, corrige para pra mim, não funcionou usando xHarbour.



#include "FiveWin.ch"

STATIC oWnd

FUNCTION Main()

LOCAL oWmaster := "joao" //??? o que e oWmaster ??

DEFINE WINDOW oWnd TITLE "Erros..." FROM -1, -1 TO -1, -1

IF file("ERROR.LOG")

SendMail(oWmaster)

ENDIF

oWnd:End()

ACTIVATE WINDOW oWnd

RETURN NIL
//---------------

//------------------------------------------------------------
function SendMail(oWmaster)


local oOutMail, oIP, mailport := 587, mailauth := .T., usuario:="joao@pleno.com.br", senha:="2698357"
local errorlog := memoread("error.log")
LOCAL VER := "3.69"
LOCAL VEMAIL := "joao@pleno.com.br"
LOCAL s_ua := "s_ua"
LOCAL vrodape := "RODAPE"
LOCAL vrodape1 := "RODAPE1"
LOCAL vrodape2 := "RODAPE2"
LOCAL vwww := "VWWW"
LOCAL logo := "LOGO"
LOCAL top_rel := "TOP REL"

WsaStartUp()

oIP :=GETHOSTBYNAME("smtp.pleno.com.br")

//msginfo(oIP,"oIP")
If oIP = "0.0.0.0"
DelLog:=.f.
WsaCleanUp()
return .f.
Endif

mailport := 587

// xHarbour nao reconhece isto???
oWmaster:SetMsg( "Sending Internet email..." )

oOutMail := TSmtp():New(GETHOSTBYNAME("smtp.pleno.com.br"))

oOutMail := TSmtp():New(GETHOSTBYNAME("smtp.pleno.com.br"), mailport, mailauth , usuario, senha)

Log_SMTP := .F.

if Log_SMTP
ooutMail:oSocket:lDebug := .T.
ooutMail:oSocket:cLogFile := "smtp.log"
endif

oOutMail:bConnecting = { || oWmaster:SetMsg( "Connecting" ) }
oOutMail:bConnected = { || oWmaster:SetMsg( "Connected" ) }
oOutMail:bDone = { || oWmaster:SetMsg( "Message sent successfully" ) , oOutMail:end(), WsaCleanUp() }
oOutMail:SendMail( "joao@pleno.com.br",; // From
{ "joao@pleno.com.br" },; // To
Ver+CRLF+"From:"+vemail+CRLF+s_ua+CRLF+vrodape1+CRLF+vrodape2+CRLF+vwww+CRLF+"Hd:"+subs(alltrim(str(nSerialHD())),1,8)+"."+subs(alltrim(str(nSerialHD())),9,3)+CRLF+logo+CRLF+ ":=:=:=:=:=:"+CRLF+errorlog,; // Msg Text
top_rel,; // Subject
{} ,"t","") // attached files
return .t.

Link to comment
Share on other sites

João, comentei no código. Tente agora.

Rogério, corrige para pra mim, não funcionou usando xHarbour.
#include "FiveWin.ch"
 
STATIC oWMaster
 
FUNCTION Main()
 
  // LOCAL oWmaster := "joao"  //??? o que e oWmaster  ?? -> é a janela principal 
//no seu ex. oWnd
 
   //DEFINE WINDOW oWnd TITLE "Erros..." FROM -1, -1 TO -1, -1
DEFINE WINDOW oWMaster TITLE "Erros..." FROM -1, -1 TO -1, -1
 
   IF file("ERROR.LOG")
 
      SendMail(oWmaster)
 
   ENDIF
 
    
   ACTIVATE WINDOW oWmaster
 
RETURN NIL
//---------------
 
//------------------------------------------------------------
function SendMail(oWmaster)
 
 
   local oOutMail, oIP, mailport := 587, mailauth := .T., usuario:="joao@pleno.com.br", senha:="2698357"
   local errorlog := memoread("error.log")
   LOCAL VER := "3.69"
   LOCAL VEMAIL := "joao@pleno.com.br"
//essas variáveis carregam valores de identificação do usuário do software, config do usuario
   LOCAL s_ua := "s_ua"
   LOCAL vrodape  := "RODAPE"
   LOCAL vrodape1 := "RODAPE1"
   LOCAL vrodape2 := "RODAPE2"
   LOCAL vwww := "VWWW"
   LOCAL logo := "LOGO"
   LOCAL top_rel := "TOP REL"
 
   WsaStartUp()
 
   oIP :=GETHOSTBYNAME("smtp.pleno.com.br")
 
   msginfo(oIP,"oIP")  //deixe ativado para ter certeza que está localizando o servidor
   If oIP = "0.0.0.0"
      DelLog:=.f.
      WsaCleanUp()
      return .f.
   Endif
 
   mailport := 587
 
   // xHarbour nao reconhece isto??? //tem que reconhecer sim

   oWmaster:SetMsg( "Sending Internet email..." )
 
   oOutMail := TSmtp():New(GETHOSTBYNAME("smtp.pleno.com.br"))
 
   oOutMail := TSmtp():New(GETHOSTBYNAME("smtp.pleno.com.br"), mailport, mailauth , usuario, senha)
 
   Log_SMTP := .F.
 
   if Log_SMTP
      ooutMail:oSocket:lDebug := .T.
      ooutMail:oSocket:cLogFile := "smtp.log"
   endif
 
   oOutMail:bConnecting = { || oWmaster:SetMsg( "Connecting" ) }
   oOutMail:bConnected  = { || oWmaster:SetMsg( "Connected" ) }
   oOutMail:bDone       = { || oWmaster:SetMsg( "Message sent successfully" ) , oOutMail:end(), WsaCleanUp() }
   oOutMail:SendMail( "joao@pleno.com.br",;     // From
                    { "joao@pleno.com.br" },;   // To
    Ver+CRLF+"From:"+vemail+CRLF+s_ua+CRLF+vrodape1+CRLF+vrodape2+CRLF+vwww+CRLF+"Hd:"+subs(alltrim(str(nSerialHD())),1,8)+"."+subs(alltrim(str(nSerialHD())),9,3)+CRLF+logo+CRLF+ ":=:=:=:=:=:"+CRLF+errorlog,;  // Msg Text
     top_rel,; // Subject
                      {} ,"t","")  // attached files
return .t.
Link to comment
Share on other sites

Rogerio, quase. Session did not complete sucessfuly.



#include "FiveWin.ch"

STATIC oWnd

FUNCTION Main()

DEFINE WINDOW oWnd TITLE "Usando SMTP Para Email"

DEFINE BUTTONBAR oBar _3D OF oWnd

SET MESSAGE OF oWnd TO "Usando SMTP Para Email" NOINSET CLOCK DATE KEYBOARD

ACTIVATE WINDOW oWnd ;
ON INIT ( SendMail( oWnd ) )

RETURN NIL

//------------------------------------------------------------

function SendMail( oWnd )


local oOutMail, oIP, mailport := 587, mailauth := .T., usuario:="joao@pleno.com.br", senha:="2426287"
local errorlog := memoread("error.log")
LOCAL VER := "3.69"
LOCAL VEMAIL := "joao@pleno.com.br"
//essas variáveis carregam valores de identificação do usuário do software, config do usuario
LOCAL s_ua := "s_ua"
LOCAL vrodape := "RODAPE"
LOCAL vrodape1 := "RODAPE1"
LOCAL vrodape2 := "RODAPE2"
LOCAL vwww := "VWWW"
LOCAL logo := "LOGO"
LOCAL top_rel := "TOP REL"

WsaStartUp()

oIP := GETHOSTBYNAME("smtp.pleno.com.br")

msginfo(oIP,"oIP") //deixe ativado para ter certeza que está localizando o servidor

If oIP = "0.0.0.0"
DelLog:=.f.
WsaCleanUp()
return .f.
Endif

mailport := 587

oWnd:SetMsg( "Sending Internet email..." )

oOutMail := TSmtp():New(GETHOSTBYNAME("smtp.pleno.com.br"))

oOutMail := TSmtp():New(GETHOSTBYNAME("smtp.pleno.com.br"), mailport, mailauth , usuario, senha)

Log_SMTP := .F.

if Log_SMTP
ooutMail:oSocket:lDebug := .T.
ooutMail:oSocket:cLogFile := "smtp.log"
endif

oOutMail:bConnecting = { || oWnd:SetMsg( "Connecting" ) }
oOutMail:bConnected = { || oWnd:SetMsg( "Connected" ) }
oOutMail:bDone = { || oWnd:SetMsg( "Message sent successfully" ) , oOutMail:end(), WsaCleanUp() }
oOutMail:SendMail( "joao@pleno.com.br",; // From
{ "joao@pleno.com.br" },; // To
Ver+CRLF+"From:"+vemail+CRLF+s_ua+CRLF+vrodape1+CRLF+vrodape2+CRLF+vwww+CRLF+"Hd:"+subs(alltrim(str(nSerialHD())),1,8)+"."+subs(alltrim(str(nSerialHD())),9,3)+CRLF+logo+CRLF+ ":=:=:=:=:=:"+CRLF+errorlog,; // Msg Text
top_rel,; // Subject
{} ,"t","") // attached files
return .t.


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...