by RiazKhan » Tue Jun 08, 2021 7:32 pm
Thanks ....for your support.
I have tried many ways...to send an email from my application....but it does not respond...
Part of the function is listed below...from this forum..
******************************************************************************************************
STATIC FUNCTION SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, aAttach, cSender, cUser, cPassword, aCc, lHtml, cPort, lNotification, lSSL )
LOCAL lOk := .F.
LOCAL oCfg, oMsg
LOCAL cCc := ""
LOCAL i
DEFAULT lHtml := "<html" $ LOWER( cMessage )
DEFAULT lNotification := .F.
DEFAULT lSSL := .F.
TRY
oCfg = CREATEOBJECT( "CDO.Configuration" )
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value = cServer
IF !EMPTY( cPort )
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := VAL( cPort )
ENDIF
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value = 2
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value = .F.
IF !EMPTY( cUser ) .AND. !EMPTY( cPassword )
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value = .T.
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value = cUser
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cPassword
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value = lSSL
ENDIF
oCfg:Update()
oMsg = CREATEOBJECT( "CDO.Message" )
oMsg:Configuration = oCfg
IF !EMPTY( cSender ) THEN cFrom = ["] + cSender + ["] + " <" + cFrom + ">"
oMsg:From = cFrom
oMsg:To = cTo
oMsg:Subject = cSubject
IF !EMPTY( aCc )
FOR i = 1 TO LEN( aCc )
IF i > 1 THEN cCc += ";"
cCc += aCc[ i ]
NEXT
oMsg:CC = cCc
ENDIF
IF !lHtml
oMsg:TextBody = cMessage
ELSE
oMsg:HTMLBody = cMessage
ENDIF
IF !EMPTY( aAttach )
FOR i = 1 TO LEN( aAttach )
oMsg:AddAttachment( aAttach[ i ] )
NEXT
ENDIF
IF lNotification
oMsg:Fields:Item( "urn:schemas:mailheader:disposition-notification-to" ):Value = cFrom
oMsg:Fields:Update()
ENDIF
oMsg:Send()
lOk = .T.
CATCH
END
RETURN lOk
***************************************************************************************
No luck....