Hu
2011-01-13 20:07:08 UTC
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
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