*-------------------------------------------------------------------------------------------------------------------------------*
Function SendMail( oDlg, cSender, cPass, cDisplay, cReply, lSave, cTo, cCC, cSubject, cMsg, lReceipt, cAttach, lMsgInfo )
*-------------------------------------------------------------------------------------------------------------------------------*
Local oEmailCfg,oEmailMsg,oError,cHtml, cLine, n
local nSuccess
nSuccess := 1
Default lReceipt := .T., lMsgInfo := .F., lSave := .T., cAttach := '', cSubject := '', cDisplay := MEMVAR->coname, cMsg := '', cCC := '', ;
cReply := cSender, cGstNo := ''
cMsg := alltrim(cMsg)
CursorWait()
cHtml:='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'
cHtml+='<HTML><HEAD>'
cHtml+='<META content="text/html; charset=windows-874" http-equiv=Content-Type>'
cHtml+='<META name=GENERATOR content="MSHTML 8.00.6001.18783">'
cHtml+='<STYLE></STYLE>'
cHtml+='</HEAD>'
cHtml+='<BODY bgColor=#ffffff>'
cHtml+='<DIV>'
// cHtml += '<DIV><FONT size=2 color=blue face=Arial>Hello How are you ?</FONT></DIV></BODY></HTML>'
cHtml += cMsg
cHtml += '</DIV></BODY></HTML>'
TRY
oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
WITH OBJECT oEmailCfg:Fields
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := "smtp.gmail.com"
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := 465
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // Remote SMTP = 2, local = 1
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := .T.
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := .T.
:Item( "http://schemas.microsoft.com/cdo/configuration/savesentitems" ):Value := lSave
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := cSender // "email@gmail.com"
:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cPass // Password
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 60
:Update()
END WITH
CATCH oError
if lMsgInfo
MsgAlert("Could not send message" +CRLF+ ;
"Error: " + TRANSFORM(oError:GenCode, NIL) +CRLF+ ;
"SubC: " + TRANSFORM(oError:SubCode, NIL) +CRLF+ ;
"OSCode: " + TRANSFORM(oError:OsCode, NIL) +CRLF+ ;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) +CRLF+ ;
"Message: " + oError:Description )
else
nSuccess := 0
end
END
oError:=NIL
TRY
oEmailMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oEmailMsg
:Configuration := oEmailCfg
:From := chr(34)+cDisplay+" "+chr(34)+ "<"+cReply+">" // cSender // This will be displayed in the From (The email id does not appear)
:To := cTo // "dutch@easyfo.com" // <----- Place your email address
:Subject := cSubject // "Email Test Message from GMail"
:ReplyTo := cReply
:MDNRequested := .F.
if !empty(cAttach)
:AddAttachment(cAttach)
end
:HTMLBody = cHtml
END WITH
oEmailMsg:Send()
CATCH oError
if lMsgInfo
MsgAlert("Could not send message" + ";" + CRLF+ ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + CRLF+;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + CRLF+ ;
"OSCode: "+ TRANSFORM(oError:OsCode, NIL) + ";" + CRLF +;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" +CRLF+ ;
"Message: " + oError:Description )
end
END
CursorArrow()
Return nSuccess
Silvio.Falconi wrote:Ducth,
perhaps now I Know how send a message
but I need some info
MDNRequested := .F. what is this ?
I need the check if the email is read ..thanks
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 89 guests