Page 1 of 1

SAMPLES\TESTSMTP.PRG

PostPosted: Wed Aug 06, 2014 3:59 pm
by karinha
C:\FWH1306\SAMPLES\TESTSMTP.PRG

Maestro, en este ejemplo, como hago para informar el puerto y contrasena?

Ejemplo:

Puerto: 465
Contrasenha: javali123 (Password)

Code: Select all  Expand view

// Testing FiveWin new Internet Outgoing mail (SMTP protocol) Class

#include "FiveWin.ch"

static oWnd

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

function Main()

   local oBar

   DEFINE WINDOW oWnd TITLE "Sending Internet Mail from FiveWin"

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar ACTION SendMail() TOOLTIP "Send Mail"

   SET MESSAGE OF oWnd TO "Ready" NOINSET DATE TIME KEYBOARD

   ACTIVATE WINDOW oWnd

return nil

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

function SendMail()

   local oOutMail, cIP

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

   WSAStartup()
   oOutMail := TSmtp():New( cIP := GetHostByName( "smtp.dominio.com.br" ) )
   MsgInfo( cIP )

   oOutMail:bConnecting = { || oWnd:SetMsg( "Connecting to smtp.dominio.com.br" ) }
   oOutMail:bConnected  = { || oWnd:SetMsg( "Connected" ) }
   oOutMail:bDone       = { || oWnd:SetMsg( "Message sent successfully" ) }

   oOutMail:SendMail( "joao@dominio.com.br",;     // From
                      { "joao@dominio.com.br" },; // To
                        "It is working!!!",;              // Msg Text
                        "Testing FiveWin Class TSmtp enhancements",; // Subject
                      { "testsmtp.prg", "testsmtp.zip" } )  // attached files

return nil

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


Gracias, saludos


Re: SAMPLES\TESTSMTP.PRG

PostPosted: Thu Aug 07, 2014 4:14 am
by Antonio Linares
Joao,

Si revisas la Clase TSmtp encontrarás esto:

METHOD New( cIPServer, nPort, lAuth, cUser, cPassword ) CLASS TSmtp

Es decir, desde el método New() se pueden especificar ambas cosas :-)

Re: SAMPLES\TESTSMTP.PRG

PostPosted: Tue Aug 12, 2014 2:20 pm
by karinha
Gracias Maestro, ahora funciona perfectamente.

Code: Select all  Expand view

// Testing FiveWin new Internet Outgoing mail (SMTP protocol) Class
// Baseado no exemplo: C:\FWH1306\SAMPLES\TESTSMTP.PRG
// Special Thanks: Vagner Wirts.

#include "FiveWin.ch"

static oWnd

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

FUNCTION Main()

   local oBar

   DEFINE WINDOW oWnd TITLE "Sending Internet Mail from FiveWin"

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar ACTION SendMail() TOOLTIP "Send Mail"

   SET MESSAGE OF oWnd TO "Ready" NOINSET DATE TIME KEYBOARD

   ACTIVATE WINDOW oWnd

return nil

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

FUNCTION SendMail()

   local oOutMail, cIP, nPort, lAuth, cUser, cPassword, cIPServer

   Default nPort := 587,  ;
           lAuth := .T.,  ;  // Obrigatorio ser .T. no meu caso.
           cUser := "joao@pleno.com.br", ;
           cPassword := "MISENHA",       ;
           cIPServer := ""

   oWnd:SetMsg( "Envio de Email Via Internet..." )

   WSAStartup()

   // Classe: TSMPT.PRG
   //METHOD New( cIPServer, nPort, lAuth, cUser, cPassword ) CONSTRUCTOR

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

   oOutMail := TSmtp():New( cIPServer, nPort, lAuth, cUser, cPassword )

   MsgInfo( cIPServer )  // cIP

   oOutMail:bConnecting = { || oWnd:SetMsg( "Conectando ao smtp.pleno.com.br..." ) }
   oOutMail:bConnected  = { || oWnd:SetMsg( "Conectado" ) }
   oOutMail:bDone       = { || oWnd:SetMsg( "Mensagem Enviada com Sucesso" ) }

   oOutMail:SendMail( "joao@pleno.com.br",;     // From
                      { "joao@pleno.com.br" },; // To
                        "Mensagens de Erros do Programa",; // Msg Text
                        "*** CONTROLE DE ERROS ***",; // Subject
                      { "error.log" } )  // attached files

                   // { "error.log", "testsmtp.zip" } )  // attached files

RETURN NIL

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


Saludos.