SAMPLES\TESTSMTP.PRG

SAMPLES\TESTSMTP.PRG

Postby karinha » Wed Aug 06, 2014 3: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: 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

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7445
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: SAMPLES\TESTSMTP.PRG

Postby Antonio Linares » Thu Aug 07, 2014 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: SAMPLES\TESTSMTP.PRG

Postby karinha » Tue Aug 12, 2014 2:20 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7445
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 131 guests