FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour SAMPLES\TESTSMTP.PRG
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
SAMPLES\TESTSMTP.PRG
Posted: Wed Aug 06, 2014 03:59 PM
C:\FWH1306\SAMPLES\TESTSMTP.PRG

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

Ejemplo:

Puerto: 465
Contrasenha: javali123 (Password)

Code (fw): Select all Collapse
// 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

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: SAMPLES\TESTSMTP.PRG
Posted: Thu Aug 07, 2014 04:14 AM

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 :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: SAMPLES\TESTSMTP.PRG
Posted: Tue Aug 12, 2014 02:20 PM
Gracias Maestro, ahora funciona perfectamente.

Code (fw): Select all Collapse
// 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion