Discussion:
HTML e-mail
(too old to reply)
Hu
2011-01-13 20:07:08 UTC
Permalink
Hi everybody !
I have to send mail with HTML body.
As I saw once in WIN32OLE.PRG a sample of OUTLOOK I started with it :
******************************************************************************
function main
******************************************************************************
if !outlook()
devpos(20,05)
devout(' Ooops !')
endi
inkey(0)
cls

******************************************************************************
STATIC PROCEDURE OUTLOOK()
******************************************************************************
priv oOL, oList, oMail, i

TRY
oOL := GetActiveObject( "Outlook.Application" )
CATCH
TRY
oOL := CreateObject( "Outlook.Application" )
CATCH
Alert( "ERROR! Outlook not avialable. [" + Ole2TxtError()+
"]" )
RETURN .f.
END
END

oOLMsg := oOL:CreateItem( 0 )

__htm_code := memoread('bolblq.htm')

* Paramentros
oOLMsg:To := "***@ig.com.br"
oOLMsg:Cc := "***@yahoo.com.br"
oOLMsg:Subject := "Teste envio XHarbour"
oOLMsg:HTMLBody := __htm_code
oOLMsg:Attachments:Add("c:\xhb12001\tst\outtst1.txt")
*oOLMsg:Send('Lets go!')
*oOLMsg:Send(.f.)
oOLMsg:ReadReceiptRequested := .T.

oOLMsg:Display(.f.)

RETURN .t.

It shows HTML file as body just as expected.
Problem is if I use SEND method always got error due SEND
parameter ???

Then I tried TipMail :
* outmail.prg
// The example outlines the steps required for composing an eMail
// and sending it to an SMTP mail server.
******************************************************************************
PROCEDURE Main
******************************************************************************
priv oSmtp, oEMail
priv cSmtpUrl
priv cSubject, cFrom, cTo, cBody, cFile

// preparing data for eMail
cSmtpUrl := "smtp://huchia:***@smtp.glad.com.br"
cSubject := "Testing HTML Body eMail" + + DtoC(Date()) + " " + Time()
cFrom := "***@glad.com.br"
cTo := "***@glad.com.br"

* HTML Body
cBody := "bolblq.htm"
__htm_code := memoread(cBody)
cBody := __htm_code

// preparing eMail object
oEMail := TIpMail():new()
oEMail:setHeader( cSubject, cFrom, cTo )
oEMail:setBody( cBody )
oEMail:attachFile( "bolblq.htm" )

// preparing SMTP object
* LOG FILE
*
oSmtp := TIpClientSmtp():new( cSmtpUrl , .t.)

// sending data via internet connection
IF oSmtp:open()
oSmtp:auth("***@glad.com.br","1978brasil")
oSmtp:sendMail( oEMail )
oSmtp:close()
? "Mail sent"
ELSE
? "Error:"
oSmtp:lastErrorMessage()
ENDIF

RETURN

This time no problem unless that BODY remains as TEXT and not HTML.

Then I´ve tried HB_SENDMAIL() but can´t grant authentication even
changing LNoAuth parameter :
* TMAIL2.PRG - Teste envio e-mail
******************************************************************************
procedure main
******************************************************************************
cls

* Dados Obrigatorios
cServer := 'smtp.glad.com.br'
nPort := 25
aCC := {'***@glad.com.br'}
aBCC := {}
cFrom := '***@glad.com.br'
aTo := {'***@glad.com.br'}
cBody := 'bolblq.htm'
cSubject := 'Teste TMAIL2 !'
aFiles := {'bolblq.htm'}
nPriority := 3
cUser := 'huchia'
cPass := '1978brasil'
cPopServer := 'pop.glad.com.br'
cReplyTo := '***@glad.com.br'

lRead := .t. // confirmation request
lTrace := .t.
lPOPAuth := .f.
lNoAuth := .f. // .f. -> tem autenticao ?
nTimeOut := 500 // 0.5 s

__ctrl := HB_SendMail( cServer, nPort, cFrom, aTo, aCC, aBCC,
cBody, cSubject, aFiles, cUser, cPass, cPopServer, nPriority, lRead,
lTrace, lPopAuth, lNoAuth, nTimeOut, cReplyTo )
if __ctrl
devpos(20,05)
devout(' Enviado !! ')
else
devpos(20,05)
devout(' Ooops !! ')
endi
inkey(0)

I really appreciate any help

Thanks ,
Hu
dlzc
2011-01-13 20:43:47 UTC
Permalink
Post by Hu
Hi everybody !
I have to send mail with HTML body.
...
Post by Hu
I really appreciate any help
http://groups.google.com/group/comp.lang.xharbour/browse_frm/thread/e05265df8160ae44

Might help, might not.

David A. Smith
Hu
2011-01-14 13:03:14 UTC
Permalink
Post by Hu
Hi everybody !
I have to send mail with HTML body.
...
Post by Hu
I really appreciate any help
http://groups.google.com/group/comp.lang.xharbour/browse_frm/thread/e...
Might help, might not.
David A. Smith
Hi David , thanks for your help.
The link gave me the answers.
There were two erros in my code :
1) cBody file name MUST include full path (I´ve read about that
already but forgot !!!)
2) Timeout must set to a value compatible with SMTP server. I´ve set
up to 5 s which is too fast. My server takes 17 s to authenticate
message.

Two more doubts :
Why using TipMail class the HTML body does not work ? I filled cBody
with the HTML string that worked with HB_SENDMAIL. Is there any other
parameter that should be configured ?
After testing mail sending I notice that TipMail is much faster than
HB_SENDMAIL. Any reason for this ?

Thanks again
Hu
dlzc
2011-01-14 19:51:56 UTC
Permalink
Dear Hu:

On Jan 14, 6:03 am, Hu <***@ig.com.br> wrote:
...
Post by Hu
Why using TipMail class the HTML body does not
work ? I filled cBody with the HTML string that
worked with HB_SENDMAIL. Is there any other
parameter that should be configured ?
After testing mail sending I notice that TipMail is
much faster than HB_SENDMAIL. Any reason for
this ?
This thread may or may not help:
http://groups.google.com/group/comp.lang.xharbour/msg/47dca1482fd1e700
... just click on "More options", then "View thread".

David A. Smith
Hu
2011-01-16 00:59:00 UTC
Permalink
...
Post by Hu
Why using TipMail class the HTML body does not
work ? I filled cBody with the HTML string that
worked with HB_SENDMAIL. Is there any other
parameter that should be configured ?
After testing mail sending I notice that TipMail is
much faster than HB_SENDMAIL. Any reason for
this ?
This thread may or may not help:http://groups.google.com/group/comp.lang.xharbour/msg/47dca1482fd1e700
... just click on "More options", then "View thread".
David A. Smith
Hi David ,
It seems the sample code of the thread has error.
I made changes including "nTimeOut" parameter and changed
"oInMail:tIPClient():new(oUrl,,ltrace)" to
"oInMail:tIPClientSmtp():new(oUrl,,ltrace)".
See sample code :
#include "common.ch"
******************************************************************************
FUNCTION main
******************************************************************************

altd()

* Parameters of SendMail() / RecvMail
* cServerIP -> Required. Smtp server name or address
* nPort -> Optional. Stmt port number
* cFrom -> Required. Email Address of who is sending
* aTo -> Required. an simple email Address, or an array
* containing multiples reciepts email address
* cMsg -> Optional. Message Body For html emails, pass the html
* filename as subject
* cSubject -> Optional. Message subject
* aFiles -> Optional. Array of files to attach to email
* cUser -> Required. Pop3 user name
* cPass -> Required. Pop user name password
* cPopServer -> Required. Pop3 server name or address
* nPriority -> Optional. Email Prioryty. 1 high 3[default] normal 5
* lower
* lRead -> Optional. Flag to indicate is user need to confirm
* reciept . default .f.
* lTrace -> Optional. Flag to indicate creation of log files
* (sendmail*.log) . default .f.
* lPopAuth -> Optional. Flag to indicate to authenticate via pop3
* server. Default .T.
* nTimeOut -> Optional. Number os ms to wait default 20000 (20s)

cServerIP := 'smtp.gladport.com.br'
nPort := 25
cFrom := '***@gladport.com.br'
aTo := {'***@ig.com.br'}
cMsg := 'c:\xhb12001\tst\email\bolblq.htm'
cSubject := "SENDMAIL.PRG - Teste envio XHarbour / " + DtoC(Date())
+ " " + Time()
aFiles := {'c:\xhb12001\tst\email\bolblq.htm'}
cUser := '***@gladport.com.br'
cPass := 'sis5572glad'
cPopServer := 'pop.gladport.com.br'
nPriority := 3
lRead := .t. // .f.
lTrace := .t.
lPopAuth := .f. // .t.
nTimeOut := 20000 // LOCAWEB -> min 17000 ms

__tsnd := SendMail(cServerIP, nPort, cFrom, aTo, cMsg, cSubject,
aFiles,cUser, cPass, cPopServer, nPriority, lRead,
lTrace ,lPopAuth ,nTimeOut)
? __tsnd

inkey(0)

__trcv := recvMail(cServerIP, nPort, cFrom, aTo, cMsg, cSubject,
aFiles,cUser, cPass, cPopServer, nPriority, lRead,
lTrace ,lPopAuth ,nTimeOut)
? __trcv

inkey(0)

RETURN nil



*
* Parameters of SendMail() / RecvMail
* cServerIP -> Required. Smtp server name or address
* nPort -> Optional. Stmt port number
* cFrom -> Required. Email Address of who is sending
* aTo -> Required. an simple email Address, or an array
* containing multiples reciepts email address
* cMsg -> Optional. Message Body For html emails, pass the html
* filename as subject
* cSubject -> Optional. Message subject
* aFiles -> Optional. Array of files to attach to email
* cUser -> Required. Pop3 user name
* cPass -> Required. Pop user name password
* cPopServer -> Required. Pop3 server name or address
* nPriority -> Optional. Email Prioryty. 1 high 3[default] normal 5
* lower
* lRead -> Optional. Flag to indicate is user need to confirm
* reciept . default .f.
* lTrace -> Optional. Flag to indicate creation of log files
* (sendmail*.log) . default .f.
* lPopAuth -> Optional. Flag to indicate to authenticate via pop3
* server. Default .T.
* nTimeOut -> Optional. Number os ms to wait default 20000 (20s)

******************************************************************************
FUNCTION SendMail()
******************************************************************************
para cServerIP, nPort, cFrom, aTo, cMsg, cSubject, aFiles, cUser,;
cPass, cPopServer, nPriority, lRead, lTrace ,lPopAuth, nTimeOut

LOCAL oInMail
LOCAL lSair := .F.
LOCAL nStart
LOCAL nRetry := 1
LOCAL oUrl
LOCAL oUrl1
LOCAL oMail
LOCAL cTo := ""
LOCAL aThisFile
LOCAL cFile
LOCAL cData2
LOCAL cFname
LOCAL cFext
LOCAL cData
LOCAL cConnect := ""
LOCAL CC := ""
LOCAL lRet := .T.
LOCAL oPop
LOCAL lSecure := .F.
LOCAL lAuthLogin := .F.
LOCAL lAuthPlain := .F.
LOCAL lConnect := .T.
LOCAL cMimeText := ""
LOCAL lConnectPlain := .f.
Local cMsgTemp
local cLastError, oAttach

/*
DEFAULT cUser TO ""
DEFAULT cPass TO ""
DEFAULT nPort TO 25
DEFAULT aFiles TO {}
DEFAULT nPriority TO 3
DEFAULT lRead TO .f.
DEFAULT lTrace to .F.
DEFAULT lPopAuth to .T.
*/

cLastError := ""
cUser := Strtran( cUser, "@", "&at;" )

IF Valtype( aTo ) == "A"
IF Len( aTo ) > 1
FOR EACH cTo IN aTo
IF HB_EnumIndex() != 1
cC += cTo + ","
ENDIF
NEXT
cC := Substr( cC, 1, Len( cC ) - 1 )
ENDIF

cTo := aTo[ 1 ]
IF Len( cC ) > 0
cTo += "," + cC
ENDIF
ELSE
cTo := Alltrim( aTo )
ENDIF

//TraceLog(cServerIP, nPort, cFrom, aTo, cMsg, cSubject, aFiles,
cUser,
// cPass, cPopServer, nPriority, lRead, lTrace ,lPopAuth)
//tracelog(cUser)

// This is required. Many smtp server, requires that first user
connect
// to popserver, to validade user, and the allow smtp access
IF cPopServer != NIL .AND. lPopAuth

oUrl1 := tUrl():New( "pop://" + cUser + ":" + cPass + "@" +
cPopServer + "/" )
oUrl1:cUserid := Strtran( cUser, "&at;", "@" )

if "gmail" in lower(cPopserver)
oUrl1:nPort := 995
endif
oPop := tIPClient():new( oUrl1,, lTrace )

* From SENDMAIL.PRG
oPop:nConnTimeout:= nTimeOut
*

if oPop:Open()
oPop:Close()
ENDIF
ENDIF

cConnect := "smtp://" + cUser + "@" + cServerIp + '/' + cTo

oUrl := tUrl():New( cConnect )
cUser := Strtran( cUser, "&at;", "@" )
oUrl:nPort := nPort
oUrl:cUserid := cUser

oMail := TipMail( ):new()
oAttach := Tipmail():new()
oAttach:setEncoder( "7-bit" )


IF (".htm" IN Lower( cMsg ) .OR. ".html" IN Lower( cMsg ) ) .and. ;
File(cMsg)
cMimeText := "text/html ; charset=ISO-8859-1"
oAttach:hHeaders[ "Content-Type" ] := cMimeText
cMsgTemp := cMsg
cMsg := MemoRead( cMsgTemp ) + chr( 13 ) + chr( 10 )
else
oMail:hHeaders[ "Content-Type" ] := "text/plain;
charset=iso8851"
ENDIF

oAttach:setbody( cmsg )
oMail:attach( oAttach )
oUrl:cFile := cTo
oMail:hHeaders[ "Date" ] := Tip_Timestamp()
oMail:hHeaders[ "From" ] := cFrom

**************************************************************
*oInMail := tIPClient():new( oUrl,, lTrace )
oInMail := tIPClientSmtp():new( oUrl,, lTrace )

* From SENDMAIL.PRG
oInMail:nConnTimeout:= nTimeOut
*
**************************************************************

IF oInMail:Opensecure()
do WHILE .T.
oInMail:GetOk()
IF oInMail:cReply == NIL
EXIT
ELSEIF "LOGIN" IN oInMail:cReply
lAuthLogin := .T.
ELSEIF "PLAIN" IN oInMail:cReply
lAuthPlain := .T.
ENDIF
ENDDO

IF lAuthLogin
IF !oInMail:Auth( cUser, cPass )
lConnect := .F.
//oInMail:Quit()
ELSE
lConnectPlain := .t.
ENDIF
ENDIF

IF lAuthPlain .AND. !lConnect
IF !oInMail:AuthPlain( cUser, cPass )
lConnect := .F.
//oInMail:Quit()
ENDIF
ELSE
IF !lConnectPlain
oInmail:Getok()
lConnect := .F.
ENDIF
ENDIF
ELSE
lConnect := .F.
ENDIF

IF !lConnect
//roby
oInMail:close()

IF !oInMail:Open()
lConnect := .F.
//roby
oInmail:close()
RETURN .F.
ENDIF

do WHILE .T.
oInMail:GetOk()
IF oInMail:cReply == NIL
EXIT
ENDIF
ENDDO
ENDIF

oInMail:oUrl:cUserid := cFrom
oMail:hHeaders[ "To" ] := cTo
oMail:hHeaders[ "Subject" ] := cSubject

FOR EACH aThisFile IN AFiles
IF Valtype( aThisFile ) == "C"
cFile := aThisFile
cData := Memoread( cFile ) + chr( 13 ) + chr( 10 )
ELSEIF Valtype( aThisFile ) == "A" .AND. Len( aThisFile ) >= 2
cFile := aThisFile[ 1 ]
cData := aThisFile[ 2 ] + chr( 13 ) + chr( 10 )
ELSE
lRet := .F.
EXIT
ENDIF
oAttach := TipMail():New()
//TODO: mime type magic auto-finder
HB_FNameSplit( cFile,, @cFname, @cFext )

IF Lower( cFile ) LIKE ".+\.(zip|jp|jpeg|png|jpg|pdf|bin|dms|lha|
lzh|exe|class|so|dll|dmg)" .or. ;
Empty(cFExt)
oAttach:SetEncoder( "base64" )
ELSE
oAttach:SetEncoder( "7-bit" )
ENDIF

cMimeText := SetMimeType( cFile, cFname, cFext )
// Some EMAIL readers use Content-Type to check for filename

IF ".html" in lower( cFext) .or. ".htm" in lower( cFext)
cMimeText += "; charset=ISO-8859-1"
ENDIF

oAttach:hHeaders[ "Content-Type" ] := cMimeText
// But usually, original filename is set here
oAttach:hHeaders[ "Content-Disposition" ] := "attachment;
filename=" + cFname + cFext
oAttach:SetBody( cData )
oMail:Attach( oAttach )
NEXT

IF lRead
oMail:hHeaders[ "Disposition-Notification-To" ] := cUser
ENDIF

IF nPriority != 3
oMail:hHeaders[ "X-Priority" ] := Str( nPriority, 1 )
ENDIF
lRet := .T.

IF lRet
cData2 := oMail:ToString()
oInmail:Write( cData2 )
oInMail:commit()
ENDIF

//oInMail:quit()
oInMail:close()

IF lRet
cLastError := ""
ENDIF

RETURN lRet

******************************************************************************
FUNCTION SetMimeType()
******************************************************************************
para cFile, cFname, cFext

cFile := Lower( cFile )

IF cFile LIKE ".+\.zip"
RETURN "application/x-zip-compressed;filename=" + cFname +
cFext
ELSEIF cFile LIKE ".+\.(jpeg|jpg|jp)"
RETURN "image/jpeg;filename=" + cFname + cFext
ELSEIF cFile LIKE ".+\.(png|bmp)"
RETURN "image/png;filename=" + cFname + cFext
ELSEIF cFile LIKE ".+\.(bmp)"
RETURN "image/bitmap;filename=" + cFname + cFext
ELSEIF cFile LIKE ".+\.html?"
RETURN "text/html;filename=" + cFname + cFext
ELSEIF cFile LIKE ".+\.pdf"
RETURN "application/pdf;filename=" + cFname + cFext
ELSEIF cFile LIKE ".+\.txt"
RETURN "test/plain;filename=" + cFname + cFext
ELSEIF cFile LIKE ".+\.(bin|dms|lha|lzh|exe|class|so|dll|
dmg)" .or. ;
Empty(cFExt)
RETURN "application/octet-stream;filename=" + cFname + cFext
ENDIF

RETURN "text/plain;filename=" + cFname + cFext

* EOF: MAIL1.PRG

******************************************************************************
FUNCTION recvMail()
******************************************************************************
para cServerIP, nPort, cFrom, aTo, cMsg, cSubject, aFiles, cUser,
cPass, ;
cPopServer, nPriority, lRead, lTrace ,lPopAuth, nTimeOut

LOCAL oInMail
LOCAL lSair := .F.
LOCAL nStart
LOCAL nRetry := 1
LOCAL oUrl
LOCAL oUrl1
LOCAL oMail
LOCAL cTo := ""
LOCAL aThisFile
LOCAL cFile
LOCAL cData2
LOCAL cFname
LOCAL cFext
LOCAL cData
LOCAL cConnect := ""
LOCAL CC := ""
LOCAL lRet := .T.
LOCAL oPop
LOCAL lSecure := .F.
LOCAL lAuthLogin := .F.
LOCAL lAuthPlain := .F.
LOCAL lConnect := .T.
LOCAL cMimeText := ""
LOCAL lConnectPlain := .f.
Local cMsgTemp
local cLastError

/*
DEFAULT cUser TO ""
DEFAULT cPass TO ""
DEFAULT nPort TO 25
DEFAULT aFiles TO {}
DEFAULT nPriority TO 3
DEFAULT lRead TO .f.
DEFAULT lTrace to .F.
DEFAULT lPopAuth to .T.
*/

cLastError := ""
cUser := Strtran( cUser, "@", "&at;" )

IF Valtype( aTo ) == "A"
IF Len( aTo ) > 1
FOR EACH cTo IN aTo
IF HB_EnumIndex() != 1
cC += cTo + ","
ENDIF
NEXT
cC := Substr( cC, 1, Len( cC ) - 1 )
ENDIF

cTo := aTo[ 1 ]

IF Len( cC ) > 0
cTo += "," + cC
ENDIF
ELSE
cTo := Alltrim( aTo )
ENDIF

// This is required. Many smtp server, requires that first user
connect
// to popserver, to validade user, and the allow smtp access
IF cPopServer != NIL .AND. lPopAuth
oUrl1 := tUrl():New( "pop://" + cUser + ":" + cPass + "@" +
cPopServer + "/" )
oUrl1:cUserid := Strtran( cUser, "&at;", "@" )
oPop := tIPClient():new( oUrl1,, lTrace )

* From SENDMAIL.PRG
oPop:nConnTimeout:= nTimeOut
*

IF oPop:Open()
? opop:list()
oPop:Close()
ENDIF
ENDIF

return nil

Thanks David
HU
c***@brturbo.com.br
2011-01-16 20:35:58 UTC
Permalink
Hu

please use xharbour from cvs.

and hb_sendmail have much more parameters on current cvs

Regards
Luiz
Hu
2011-01-17 09:46:14 UTC
Permalink
Post by c***@brturbo.com.br
Hu
please use xharbour from cvs.
and hb_sendmail have much more parameters on current cvs
Regards
Luiz
Hi Luiz,
I will do it.
Just for curiosity : Why in SENDMAIL.PRG TipMail:new() it´s declared
twice ?

....
oMail := TipMail( ):new()
oAttach := Tipmail():new()

it could be something like ?
oMail := TipMail( ):new()
oMail:Attachments() ...

Thanks
Hu
Klas Engwall
2011-01-18 01:07:31 UTC
Permalink
Hu,
Just for curiosity : Why in SENDMAIL.PRG TipMail:new() it=B4s declared
twice ?
....
oMail :=3D TipMail( ):new()
oAttach :=3D Tipmail():new()
it could be something like ?
oMail :=3D TipMail( ):new()
oMail:Attachments() ...
You are looking at it from the wrong direction. All the parts of the email are
separate objects of the same class, the tipMail class. Every object has an
::aAttachments array, but only the one in oMail is used. It is filled with
oAttach objects (body and attachments).

If you look further down in the code you will find a loop that creates an
additional oAttach object for each attachment in the aFiles array and attaches
it to the ::aAttachments array of oMail. In the end every object is converted to
a string in a similar manner and added to the output string (the email being
sent to the mail server) using the same ToString() method of the tipMail class
(called recursively for the headers, the body and all attachments). Take a look
at the tipMail class in mail.prg and you will see what I mean.

Regards,
Klas

-------
klas dot engwall at engwall dot com

http://www.engwall.com/clipper/

The LFN Library for Clipper
The LanMan Library for Clipper
The NFPAT1A Timeslice release patch for the Nanforum Toolkit
Hu
2011-01-18 11:14:37 UTC
Permalink
Post by Klas Engwall
Hu,
Just for curiosity : Why in SENDMAIL.PRG TipMail:new() it=B4s declared
twice ?
....
oMail   :=3D TipMail( ):new()
oAttach :=3D Tipmail():new()
it could be  something like ?
oMail   :=3D TipMail( ):new()
oMail:Attachments() ...
You are looking at it from the wrong direction. All the parts of the email are
separate objects of the same class, the tipMail class. Every object has an
::aAttachments array, but only the one in oMail is used. It is filled with
oAttach objects (body and attachments).
If you look further down in the code you will find a loop that creates an
additional oAttach object for each attachment in the aFiles array and attaches
it to the ::aAttachments array of oMail. In the end every object is converted to
a string in a similar manner and added to the output string (the email being
sent to the mail server) using the same ToString() method of the tipMail class
(called recursively for the headers, the body and all attachments). Take a look
at the tipMail class in mail.prg and you will see what I mean.
Regards,
Klas
-------
klas dot engwall at engwall dot com
http://www.engwall.com/clipper/
The LFN Library for Clipper
The LanMan Library for Clipper
The NFPAT1A Timeslice release patch for the Nanforum Toolkit
Hi Klas !

Thanks for tip.
Would you clarify other thing ?

In SENDMAIL.PRG there is a loop :
....
WHILE .T.
oInMail:GetOk()
IF oInMail:cReply == NIL
EXIT
ELSEIF "LOGIN" IN oInMail:cReply
lAuthLogin := .T.
ELSEIF "PLAIN" IN oInMail:cReply
lAuthPlain := .T.
ENDIF
ENDDO
....

If I do this :

lAuthLogin := .T.
/*
WHILE .T.
oInMail:GetOk()
IF oInMail:cReply == NIL
EXIT
ELSEIF "LOGIN" IN oInMail:cReply
lAuthLogin := .T.
ELSEIF "PLAIN" IN oInMail:cReply
lAuthPlain := .T.
ENDIF
ENDDO
*/

It´s much faster. Is there any problem in doing this ?

Tia
Hu
c***@gmail.com
2011-01-18 18:16:30 UTC
Permalink
Post by Hu
Post by Klas Engwall
Hu,
Just for curiosity : Why in SENDMAIL.PRG TipMail:new() it=B4s declared
twice ?
....
oMail   :=3D TipMail( ):new()
oAttach :=3D Tipmail():new()
it could be  something like ?
oMail   :=3D TipMail( ):new()
oMail:Attachments() ...
You are looking at it from the wrong direction. All the parts of the email are
separate objects of the same class, the tipMail class. Every object has an
::aAttachments array, but only the one in oMail is used. It is filled with
oAttach objects (body and attachments).
If you look further down in the code you will find a loop that creates an
additional oAttach object for each attachment in the aFiles array and attaches
it to the ::aAttachments array of oMail. In the end every object is converted to
a string in a similar manner and added to the output string (the email being
sent to the mail server) using the same ToString() method of the tipMail class
(called recursively for the headers, the body and all attachments). Take a look
at the tipMail class in mail.prg and you will see what I mean.
Regards,
Klas
-------
klas dot engwall at engwall dot com
http://www.engwall.com/clipper/
The LFN Library for Clipper
The LanMan Library for Clipper
The NFPAT1A Timeslice release patch for the Nanforum Toolkit
Hi Klas !
Thanks for tip.
Would you clarify other thing ?
....
WHILE .T.
            oInMail:GetOk()
            IF oInMail:cReply == NIL
               EXIT
            ELSEIF "LOGIN" IN oInMail:cReply
               lAuthLogin := .T.
            ELSEIF "PLAIN" IN oInMail:cReply
               lAuthPlain := .T.
            ENDIF
ENDDO
....
lAuthLogin := .T.
/*
WHILE .T.
       oInMail:GetOk()
       IF oInMail:cReply == NIL
           EXIT
       ELSEIF "LOGIN" IN oInMail:cReply
           lAuthLogin := .T.
       ELSEIF "PLAIN" IN oInMail:cReply
           lAuthPlain := .T.
       ENDIF
ENDDO
*/
It´s much faster. Is there any problem in doing this ?
Tia
Hu
yes. you will have many server answers pending to read

Regards
Luiz
Hu
2011-01-19 13:22:05 UTC
Permalink
Post by c***@gmail.com
Post by Hu
Post by Klas Engwall
Hu,
Just for curiosity : Why in SENDMAIL.PRG TipMail:new() it=B4s declared
twice ?
....
oMail   :=3D TipMail( ):new()
oAttach :=3D Tipmail():new()
it could be  something like ?
oMail   :=3D TipMail( ):new()
oMail:Attachments() ...
You are looking at it from the wrong direction. All the parts of the email are
separate objects of the same class, the tipMail class. Every object has an
::aAttachments array, but only the one in oMail is used. It is filled with
oAttach objects (body and attachments).
If you look further down in the code you will find a loop that creates an
additional oAttach object for each attachment in the aFiles array and attaches
it to the ::aAttachments array of oMail. In the end every object is converted to
a string in a similar manner and added to the output string (the email being
sent to the mail server) using the same ToString() method of the tipMail class
(called recursively for the headers, the body and all attachments). Take a look
at the tipMail class in mail.prg and you will see what I mean.
Regards,
Klas
-------
klas dot engwall at engwall dot com
http://www.engwall.com/clipper/
The LFN Library for Clipper
The LanMan Library for Clipper
The NFPAT1A Timeslice release patch for the Nanforum Toolkit
Hi Klas !
Thanks for tip.
Would you clarify other thing ?
....
WHILE .T.
            oInMail:GetOk()
            IF oInMail:cReply == NIL
               EXIT
            ELSEIF "LOGIN" IN oInMail:cReply
               lAuthLogin := .T.
            ELSEIF "PLAIN" IN oInMail:cReply
               lAuthPlain := .T.
            ENDIF
ENDDO
....
lAuthLogin := .T.
/*
WHILE .T.
       oInMail:GetOk()
       IF oInMail:cReply == NIL
           EXIT
       ELSEIF "LOGIN" IN oInMail:cReply
           lAuthLogin := .T.
       ELSEIF "PLAIN" IN oInMail:cReply
           lAuthPlain := .T.
       ENDIF
ENDDO
*/
It´s much faster. Is there any problem in doing this ?
Tia
Hu
yes. you will have many server answers pending to read
Regards
Luiz- Ocultar texto das mensagens anteriores -
- Mostrar texto das mensagens anteriores -
Hi Luiz ,
It´s first time I´m dealing with email stuff so my doubts are of very
basic level !
Despite I can already send HTML body email with no problem it´s only a
test for now.
The whole project is at very beginning !

Thanks for now
Hu

Loading...