Send Email

Send Email

Postby Kleyton » Fri Jul 14, 2006 12:23 pm

As to send email in Fivewin Clipper?
Kleyton
Fwh906
Brazil
Kleyton
 
Posts: 49
Joined: Thu Dec 22, 2005 12:50 pm

Postby Antonio Linares » Fri Jul 14, 2006 1:36 pm

Kleyton,

Please review samples\TestMail.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41408
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Kleyton » Fri Jul 14, 2006 5:24 pm

It would like to send e-mails without needing outlook for example. That it functioned in any version of windows.
Kleyton
Fwh906
Brazil
Kleyton
 
Posts: 49
Joined: Thu Dec 22, 2005 12:50 pm

Postby R.F. » Fri Jul 14, 2006 7:42 pm

check TestSMTP.prg works without Outlook
Saludos
R.F.
R.F.
 
Posts: 840
Joined: Thu Oct 13, 2005 7:05 pm

Postby Kleyton » Sat Jul 15, 2006 2:29 pm

Already I tested, but it does not send nothing.

It wanted another option.
Kleyton
Fwh906
Brazil
Kleyton
 
Posts: 49
Joined: Thu Dec 22, 2005 12:50 pm

Postby DanielPuente » Sat Jul 15, 2006 4:07 pm

Kleyton:

Search for tSmtp class modified by Luis Krause Mantilla, y have no problems sending email with that class:

Code: Select all  Expand view
Function EnvMail(oBrw)

Local oBar, cHost :=SPAC(40), cSender := spac(40), hFocus
local cSubject := Space( 100 ), cMsg := Space( 255 ), lReceipt := .T.
Local SEL_FIELD1:={ { || SOLICITA->NOMBRE},{ || SOLICITA->EMAIL }},;
         SEL_ENC1:={ "Nombre","Email"} ,cPaso:=.T.,cMail:=SPAC(40)
Local cRegis:=AUTORIZA->(RECNO()),cMsg2,cNombre:=spac(40),oEnvia, lAuth:=.T.
cSender := param->sender
cHost :=PARAM->SMTP

SELEAGREGA("SOLICITA",239,129,.F.,SEL_FIELD1,SEL_ENC1,2,"Destino para: Af. "+ALLTRIM(LEFT(AUTORIZA->APEYNOMB,25))+;
           " - "+IF(!EMPTY(AUTORIZA->PARTIDO),AUTORIZA->PARTIDO,BUS_DES("PADRON",3,AUTORIZA->NROBENEF,"PARTIDOUG")) )

IF SALIR # 2

      cNOmbre:=SOLICITA->NOMBRE
      if !empty(SOLICITA->EMAIL)
            cMail:=SOLICITA->EMAIL
      else
            cPaso:=pidemail(@cMail)
      endif

    if AUTORIZA->ESTADO == 'PENDI'
      MSGSTOP(oemtoansi('La pr ctica seleccionada a£n no ha sido auditada'),oemtoansi('No puede enviar pr cticas pendientes'))
      cPaso:=.F.
    endif

      IF cPaso

            cSubject:="Cisbo XI-Solic.Autoriz.Nº "+PADL(AUTORIZA->NUMERO,5,"0")+" ("+;
                         IF(AUTORIZA->ESTADO="AUTOR","AUTORIZADA",IF(AUTORIZA->ESTADO="RECHA","RECHAZADA",""))+")"

            // my defaults add by Quim
            cMsg    := ;
                "Por la presente comunicamos "+IF(AUTORIZA->ESTADO="AUTOR","LA AUTORIZACION",IF(AUTORIZA->ESTADO="RECHA",;
                "EL RECHAZO",IF(AUTORIZA->ESTADO='R.TRA',"EL RECHAZO TRANSITORIO","")))+" de la siguiente práctica:"+CRLF+;
                     +SPAC(50)+;
                     +CRLF+;
              "Número de Autorización: "+PADL(AUTORIZA->NUMERO,5,"0")+CRLF+;
              "Afiliado:  "+AUTORIZA->NROBENEF+" - "+AUTORIZA->APEYNOMB+CRLF+;
              "Partido:   "+IF(!EMPTY(AUTORIZA->PARTIDO),AUTORIZA->PARTIDO,BUS_DES("PADRON",3,AUTORIZA->NROBENEF,"PARTIDOUG"))+CRLF+;
              "Práctica:  "+BUS_DES("PRACTICA",1,AUTORIZA->PRACTICA,"NOMBRE")+CRLF+;
              "Prestador: "+ALLTRIM(AUTORIZA->PRESTADOR)+" Dir.: "+ALLTRIM(BUS_DES("PROVEEDO",2,AUTORIZA->PRESTADOR,"DIRECCION"))+;
                                                                        " Loc.: "+ALLTRIM(BUS_DES("PROVEEDO",2,AUTORIZA->PRESTADOR,"LOCALIDAD"))+;
                                                       " Tel.: "+ALLTRIM(BUS_DES("PROVEEDO",2,AUTORIZA->PRESTADOR,"TELEFONO"))+CRLF+;
              "Observaciones:  "+AUTORIZA->RESPUESTA+CRLF
            IF AUTORIZA->ESTADO=='AUTOR'
            cMsg2:= ;
              SPAC(50)+CRLF+;
              +SPAC(50)+CRLF+;
              +SPAC(50)+CRLF+;
              "La presente autorización posee 30 dias de vigencia y deberá ser adjuntada al resto de la documentación"+CRLF+;
              "que habitualmente se acompaña en la facturación mensual. En el resumen mensual de facturación deberá incluirse "+;
              "el codigo de autorización de cada práctica facturada."
            ELSE
            cMsg2:= ""
            ENDIF

            // end by Quim

            Define Window oWnd ;
                FROM 5,5 TO 29,86;
               Title oemtoansi("Enviar EMail - Autorizaci¢n N§ ")+PADL(AUTORIZA->NUMERO,5,"0")+;
                                " - Para: "+cNombre ;
               Color GetSysColor( COLOR_WINDOWTEXT ), GetSysColor( COLOR_BTNFACE )

            Define ButtonBar oBar _3D Of oWnd
            oBar:SetFont( TFont():New( "MS Sans Serif", 0, -11,, .T. ) )  // to avoid runtime error in TBtnBmp class!!!

            Define Button oEnvia of oBar Prompt "S" Group ;
               Action SendMail( oBrw,cRegis, oWnd, cMail, Alltrim( cHost ), AllTrim( cSender ), AllTrim( cSubject ),;
                                 AllTrim( cMsg ), lReceipt,cMsg2 );

Static Function SendMail( oBrw,cRegis,oDlg,cDestino,cHost, cSender, cSubject, cMsg, lReceipt,cMsg2 )
Local oMail, oInit,SS
Local cUser:="cores8@speedy.com.ar",cPass:="690810"

cUser:=ALLTRIM(PARAM->SENDER)
SS=SECONDS()
// initialize sockets (or nothing will happen) - it's a quirk in GetHostByName(), not TSmtp
oInit := TSmtp():New( cHost )
// no let's go for our socket
*oMail := TSmtp():New( cHost, , lAuth, cUser, cPass ) // [jlalin], IBTC

oMail := TSmtp():New( cHost,,.T.,cUser,cPass )
oMail:nGMT := -8   // Pacific Standard Time (GMT -08:00) - Adjust this to your own Time Zone!

// uncomment next line if you experience problems while sending email / descomentar sig. l¡nea en caso de experimentar problemas al enviar correo
oMail:nDelay := 1

//oMail:lTxtAsAttach := .F.                       // uncomment to force txt, log and htm files as inline as opposed to attachement
oMail:oSocket:lDebug := .T.                     // uncomment to create log file
oMail:oSocket:cLogFile := "smtp.log"
OMAIL:bDone={|| TONE(1000,1),MSGINFO('Mail enviado con exito en '+NTRIM((SECONDS()-SS))+' Segundos','Aviso') ,;
                REEMPLAZA(oBrw,cRegis),oWnd:End()}

oMail:bConnecting := {|| oWnd:SetMsg( "Conectando a " + cHost + " (" + oMail:cIPServer + ") and waiting for response..." ) }
oMail:bConnected  := {|| oWnd:SetMsg( "Conectado y enviando email..." ) }

cSender:=ALLTRIM(cSender)
cDestino:=ALLTRIM(cDestino)
oMail:SendMail( ;
   cSender, ;                                    // from/de
   { cDestino }, ;  // to/para (arreglo) - I use cSender here also because it's an "autotest". Actually you would type a different address here
    cMsg,;
   cSubject,;     // Subject/Asunto
   {}, ;  //  Array of filenames to attach/Arreglo de nombres de archivos a agregar
   {}, ;         // aCC
   {}, ;         // aBCC
   lReceipt, ;    // Return Receipt/acuse de recibo
   cMsg2 )         // msg in HTML format/mensaje en HTML

      oInit:end()
      SS=SECONDS()

Return .T.



Regards,
Daniel Puente
Mar del Plata, Argentina
danielpuente@speedy.com.ar
puenteda@hotmail.com
DanielPuente
 
Posts: 108
Joined: Sun Oct 09, 2005 6:12 pm
Location: Mar del Plata - Argentina

My sendmail is work well.

Postby dutch » Wed Jul 19, 2006 7:14 am

Dear Kleyton,

This is my sendmail procedure is working perfectly for me and it may help.

*-----------------------------*
Static Function SendMails(aRecNo)
local mDlg, oGet[4], oBtn[2]
local lSave := .F.
local cAtt, cSub, cText
local cHost, aHost, aAtt

aAtt := {}
aHost := {}
OPENFILE('EZMAIL','MAL')
do while !MAL->(Eof())
aadd( aHost, left(rtrim(MAL->MAL_ADDR)+' ('+rtrim(MAL->MAL_SMTP)+')'+space(360),360) )
MAL->(DbSkip())
end
CLOSEFILE('MAL')

if !empty(aHost)
cHost := aHost[1]
cSub := space(100)
cText := space(4096)

DEFINE DIALOG mDlg RESOURCE 'EMAIL' TITLE TE('ข้อความที่ต้องการส่ง','Enter sending message') FONT MEMVAR->oFont

REDEFINE COMBOBOX oGet[1] VAR cHost ITEMS aHost ID 101 OF mDlg
REDEFINE GET oGet[2] VAR cSub ID 102 OF mDlg
REDEFINE BTNGET oGet[3] VAR cAtt ID 103 OF mDlg ;
ACTION (cAtt := cGetFile('Jpeg |*.JPG|Bitmap |*.BMP|','Load From File',,'IMAGE\',,.T.), oGet[3]:Refresh(), oGet[4]:SetFocus())
* ACTION (SelFile(oGet[3],'.','*.BMP',rtrim(cAtt)), oGet[4]:SetFocus())

REDEFINE GET oGet[4] VAR cText ID 104 OF mDlg MULTILINE

oGet[4]:bGotFocus := {|| oGet[4]:SetPos(0) }

REDEFINE SBUTTON oBtn[1] ID 11 ;
RESOURCE 'SENDMAIL', 'SENDMAIL', 'SENDMAIL', 'SENDMAIL' ;
PROMPT TE('ส่ง','&Send') ;
WHEN (!empty(cHost).and.!empty(cSub)) ;
ACTION (lSave := .T., mDlg:End()) ;
COLOR {|oBtn| If( oBtn:lMouseOver, CLR_YELLOW, CLR_BLACK ) } ;
TEXT ON_RIGHT

REDEFINE SBUTTON oBtn[2] ID 12 ;
RESOURCE 'CANCEL', 'CANCEL', 'CANCEL', 'CANCEL' ;
PROMPT TE('ยกเลิก','&Cancel') ;
ACTION ( mDlg:End() ) ;
COLOR {|oBtn| If( oBtn:lMouseOver, CLR_YELLOW, CLR_BLACK ) } ;
TEXT ON_RIGHT


ACTIVATE DIALOG mDlg CENTER RESIZE16

if lSave
if !empty(cAtt)
aadd( aAtt, cAtt )
end
MsgRun( "This messages is sending now",;
"E-mail is sending, please wait...",;
{ | oDlg | UpdCaption( oDlg, cHost, cSub, aAtt, cText ) } )
end
else
MsgStop(TE('ติตั้งบัญชีอินเทอร์เน็ตก่อนใช้ข้อนี้','Please set up internet account before use'))
end
return nil

*--------------------------------*
static function UpdCaption( oDlg, cHostName, cSubject, aAtt, cMsg )
local n, lMsgInfo, cHost, cSender, cTo, cCC
lMsgInfo := .F.

cHost := subs(cHostName,at('(',cHostName)+1,(at(')',cHostName)-at('(',cHostName))-1)
cSender := rtrim(subs(cHostName,1,at('(',cHostName)-1))

for n := 1 to len(aRecNo)
GST->(DbGoTo(aRecNo[n]))
cTo := lower(rtrim(GST->GST_EMAIL))
SendMail( oDlg, cHost, cSender, cTo, cCC,cSubject, cMsg, .F., aAtt, .F. )
oDlg:cMsg := "The messages have sent successfully "+;
LTrim( Str( nCount ) ) + " mail(s)"
oDlg:Refresh()
SysRefresh()
next
return nil

*------------------------------------------------------------------*
Function SendMail( oDlg, cHost, cSender, cTo, cCC, cSubject, cMsg, lReceipt, aAttach, lMsgInfo )
Local oMail, oInit
Default aAttach := {}, lReceipt := .F., lMsgInfo := .T.
// initialize sockets (or nothing will happen) - it's a quick in GetHostByName(), not TSmtp
oInit := TSmtp():New( cHost )
// no let's go for our socket
oMail := TSmtp():New( cHost )
oMail:nGMT := +7 // Pacific Standard Time (GMT -08:00) - Adjust this to your own Time Zone!

// uncomment next line if you experience problems while sending email / descomentar sig. lกnea en caso de experimentar problemas al enviar correo
oMail:nDelay := 1

//oMail:lTxtAsAttach := .F. // uncomment to force txt, log and htm files as inline as opposed to attachement
oMail:oSocket:lDebug := .T. // uncomment to create log file
oMail:oSocket:cLogFile := "smtp.log"

oMail:bConnecting := {|| oDlg:SetMsg( "Connecting to " + cHost + " (" + oMail:cIPServer + ") and waiting for response..." ) }
oMail:bConnected := {|| oDlg:SetMsg( "Connected and sending mail and attachments..." ) }
if lMsgInfo
oMail:bDone := {|| MsgInfo('Mail sent complete') }
else
oMail:bDone := {|| nCount++ }
end

oMail:SendMail( ;
cSender, ; // from/de
{ cTo }, ; // to/para (arreglo) - I use cSender here also because it's an "autotest". Actually you would type a different address here
cMsg,; // "Hi guys:" + CRLF + "I've sent this from within FiveWin using TSmtp class" + CRLF + "This is just my first attempt to see if it works.",; // Body/Mensaje
cSubject,; // Subject/Asunto
aAttach ; // Array of filenames to attach/Arreglo de nombres de archivos a agregar
) // msg in HTML format/mensaje en HTML

oInit:end()
Return .T.
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Postby Gale FORd » Wed Jul 19, 2006 3:06 pm

We are using authentication and I cannot get tsmtp() modified by Luis Krause Mantilla to work. It just stops after it sends the user name to server.

I did not have the time to troubleshoot it, so I just returned to blat for smtp email.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby R.F. » Wed Jul 19, 2006 4:14 pm

Use funcky SMTP component it supports authentication
Saludos
R.F.
R.F.
 
Posts: 840
Joined: Thu Oct 13, 2005 7:05 pm


Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 4 guests