FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Sending e-mail with CDO and SSL
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Sending e-mail with CDO and SSL
Posted: Tue Mar 26, 2013 05:12 PM

To All Concerned

I found this thread in the FW Spanish forum and noticed in one of the links the use of SSL and CDO to send e-mail

viewtopic.php?f=6t=13175

Within the thread was a link to a VIsual FoxPro forum which gives an example of using CDO and SSL..

http://www.portalfox.com/index.php?name ... me=Printer

I have not tried the above code, but I thought it was worth a look for those who use FWH to send e-mail thru their apps.

Let me know if anyone is successful using the FoxPro code.

Thanks
Rick Lipkin

&

Posts: 120
Joined: Wed Mar 11, 2009 07:32 PM
Re: Sending e-mail with CDO and SSL
Posted: Wed Mar 27, 2013 04:57 PM
hi,,,

Code (fw): Select all Collapse
Function Config_eMail(cdest, cfiles )

聽 Local cUser,cPass,cRemt, cCC, cCCO, cTxt, cSubject
聽 local lRet := .f.
聽 local oCfg, oError
聽 local cServ :=alltrim(correo:smtp) 聽 聽 // 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽aServs[nServ][2] 聽//--> SERVIDOR SMTP - "smtp.servidor.com.br"
聽 local nPort :=val(alltrim(correo:puerto)) 聽 // 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 aServs[nServ][3]
聽 local lAut 聽:=.t.
聽 local lSSL 聽:=.f. 聽 聽 聽 聽 聽 聽 // 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽aServs[nServ][4]
聽
聽 public correo
聽 if cfiles=nil
聽 聽 聽aAttach:={}
聽 else
聽 聽 聽aAttach:=cfiles
聽 endif 聽 
聽
聽 
聽 cPass:=alltrim(correo:contra)
聽 cuser:=alltrim(correo:usuario)
聽 ctxt:= correo:MENSA 聽 
聽 csubject:=correo:texto
聽 ccc:=""
聽 ccco:=""
聽 cRemt:=alltrim(correo:usuario)
聽// cdest:="chino72vale@hotmail.com" 聽 // ay que pasas esta informacion ok
聽 cCC:=""
聽 cCCO:=""
聽// aAttach:=CFILES 聽 // serian los archivos anexados we
聽 
聽 if Empty(cPass) .or. Empty(cRemt) .or. empty(cDest) 
聽 聽 聽? "falta datos para mandar correo,,,, destino/ remitente / usuario checar "
聽 聽 聽return .f.
聽 endif 聽 
聽 
聽 TRY
聽 聽 oCfg := CREATEOBJECT( "CDO.Configuration" )
聽 聽 聽 WITH OBJECT oCfg:Fields
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" 聽 聽 聽 ):Value := cServ
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" 聽 ):Value := nPort
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" 聽 聽 聽 聽):Value := 2
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := lAut
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" 聽 聽 聽 ):Value := lSSL
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" 聽 聽 ):Value := cUser
聽 聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" 聽 聽 ):Value := cPass
聽 聽 聽聽 聽聽 聽 聽 :Update()
聽 聽 聽 END WITH
聽 聽 聽 lRet := .t.
聽 CATCH oError
聽 聽 MsgInfo( "No se pudo enviar e-Mail!" 聽+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+ ;
聽 聽 聽 聽 聽 聽 聽"Mensaje: " 聽 + oError:Description, "Atenci贸n" )

聽 END
聽 //--> FIM DAS CONFIGURA脟OES.
聽 if lRet
聽 聽 聽lRet := Envia_eMail(oCfg,cRemt,cDest, cCC, cCCO, cTxt, cSubject)聽 聽 
聽 endif
聽 聽
Return lRet
聽
********************************************************************************
Function Envia_eMail(oCfg,cFrom, cTo, cCC, cBCC, cMsg, cSubject)
聽
聽 local cToken
聽 local lRet := .f. , Omsg , x, i, loBP
聽聽 聽
聽 聽 聽 聽TRY
聽 聽 聽 聽 聽oMsg := CREATEOBJECT ( "CDO.Message" )
聽 聽 聽 聽 聽 聽WITH OBJECT oMsg
聽 聽 聽 聽 聽 聽 聽 聽 :Configuration = oCfg
聽 聽 聽 聽 聽 聽 聽 聽 :From = cFrom 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 :To = cTo
聽 聽 聽 聽 聽 聽 聽 聽 :CC = cCC
聽 聽 聽 聽 聽 聽 聽 聽 :BCC = cBCC
聽 聽 聽 聽 聽 聽 聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 :Subject = cSubject
聽 聽 聽 聽 聽 聽 聽 聽 :TextBody = cMsg
聽 聽 聽 聽 聽 聽 聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 For x := 1 To Len( aAttach )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 if aAttach[x] <> NIL
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽:AddAttachment(AllTrim(aAttach[x]))
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽 聽 聽 Next
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 :HTMLBody = "<p><img src='cid:id_imagen10'></p>" +"<p>La imagen de arriba esta embebida en el mensaje.</p>"
聽 聽 聽 聽 聽 聽 聽 聽 loBP:=:AddRelatedBodyPart("c:\faceleben\kasto2.bmp", "id_imagen10", 1)
聽 聽 聽 聽 聽 聽 聽 聽 WITH OBJECT loBP:Fields
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 :Item("urn:mailheader:Content-ID") = "id_imagen10"
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 :Update()
聽 聽 聽 聽 聽 聽 聽 聽 END WITH
聽 聽 聽 聽 聽 聽 聽 聽 :CreateMHTMLBody("File://c:\faceleben\suave.html",0)
聽 聽 聽 聽 聽 聽 聽 聽 :Send()
聽 聽 聽 聽 聽 聽END WITH
聽 聽 聽 聽 聽 聽lRet := .t.
聽 聽 聽 聽CATCH
聽 聽 聽 // 聽 聽 MsgInfo("No se pudo mandar la factura ")
聽 聽 聽 聽 聽 聽lRet := .f.
聽 聽 聽 聽 聽END
聽
聽 聽 
Return lRet

**************************************************************
* Enviando emails *
* *
* Desenvolvedor: Ricardo de Moura Marques *
* email: ricardomouramarques@hotmail.com *
* *
* Agradecimentos ao Alessandro Seribeli Barreto - "Ale SB" *
* pelo c贸digo inicial, sem o qual, esse projeto *
* n茫o seria poss铆vel *
* *
***************************************************************



sas
Benjamin Casarrubias Moreno
Cd. Obreg贸n, Sonora, M茅xico
chino72vale@hotmail.com
Fivewin 24.04, Harbour 3.3, xharbour 1.2.1, Fivelinux, Visual Estudio 2022
Oracle Api Rest, SDK Contpaq, Facturaci贸n Electr贸nica, XML DIOT 2025
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Sending e-mail with CDO and SSL *ERROR*
Posted: Thu Mar 28, 2013 07:59 PM
I am trying this out. Here is my code for the send function:

Code (fw): Select all Collapse
Function CDOSendMail( aTabMail )
聽 聽 Local oEmailCfg,oEmailMsg

聽 聽 TRY
聽 聽 聽 聽oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
聽 聽 聽 WITH OBJECT 聽oEmailCfg:Fields
聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := 聽 TRIM( aTabMail[01] ) //"mail.xxxxxxxx.com"
聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := 聽aTabMail[11] // 25
聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 聽 // Remote SMTP = 2, local = 1
聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := 聽aTabMail[08] // .T.
聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := 聽.T.
聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := TRIM( aTabMail[09] ) // 聽"xxanser@xxxxxxxx.com"
聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := TRIM( aTabMail[10] ) // "xxxxxx"
聽 聽 聽 聽 聽:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 30
聽 聽 聽 聽 聽:Update()
聽 聽 聽 END WITH
聽 聽 CATCH oError
聽 聽 聽 MsgInfo( "Could not create message configuration" + ";" 聽+ ;
聽 聽 聽 聽 聽 聽 聽"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
聽 聽 聽 聽 聽 聽 聽"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
聽 聽 聽 聽 聽 聽 聽"OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
聽 聽 聽 聽 聽 聽 聽"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
聽 聽 聽 聽 聽 聽 聽"Message: " + oError:Description )
聽 聽 聽 聽Return .F.
聽 聽 END
聽 聽 oError:=NIL

聽 聽 TRY
聽 聽 聽oEmailMsg := CREATEOBJECT ( "CDO.Message" )
聽 聽 聽WITH OBJECT oEmailMsg
聽 聽 聽 聽 :Configuration = 聽oEmailCfg
聽 聽 聽 聽 :From = aTabMail[02] //chr(34)+" Anser K.K. "+chr(34)+ "<anser@xxxxxxxx.com>" // This will be displayed in the From (The email id does not appear)
聽 聽 聽 聽 :To = TRIM( aTabMail[03] ) // "xxanserkk@xxxxx.com" 聽 聽// <----- 聽 Place the TO email address
聽 聽 聽 聽 :Subject = aTabMail[04] // "This is a Tst message"
聽 聽 聽 聽 //:ReplyTo = 聽aTabMail[02] //"xxanser@xxxxxxxxx.com" 
聽 聽 聽 聽 //:Sender = 聽aTabMail[02] //"xxanser@xxxxxxxxx.com" 聽// Read Receipt message is send to this
聽 聽 聽 聽 //:Organization = 聽TRIM( aTabMail[02] ) // "My xxxxxx Company" 聽 聽// "My Company Name"
聽 聽 聽 聽 :MDNRequested = .T.
聽 聽 聽 聽 :HTMLBody = 聽"<HTML> " + TRIM( aTabMail[05] ) + " </HTML>"
聽 聽 聽 聽 IF LEN( aTabMail[06] ) > 0
聽 聽 聽 聽 聽 聽 For nEle := 1 To Len( aTabMail[06] )
聽 聽 聽 聽 聽 聽 聽:AddAttachment( ALLTRIM(aTabMail[06][nEle] )) // := AllTrim( aAttach[ nEle ] )
聽 聽 聽 聽 聽 聽 Next
聽 聽 聽 聽 ENDIF
聽 聽 聽 聽 :Send()
聽 聽 聽END WITH
聽 聽 聽SysRefresh()
聽 聽 CATCH oError
聽 聽 聽 聽 
聽 聽 聽 聽MsgInfo( "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 )
聽 聽 聽 聽Return .F.
聽 聽 
聽 聽 END

Return( .t. )


On my non-SSL service, it works fine. However, when on an email account requiring SSL, we see the following error from the Send( )

DISP_E_MEMBERNOTFOUND

I've tried a websearch and found there was a thread on this in the Five Win forum, but what worked for someone else didn't fix it here. The values in the TabMail array are accurate.

I hope someone can succeed with this problem.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 120
Joined: Wed Mar 11, 2009 07:32 PM
Re: Sending e-mail with CDO and SSL
Posted: Thu Mar 28, 2013 08:20 PM
hi, tim

Code (fw): Select all Collapse
聽' Configura las opciones para el login en el SMTP 聽 
聽 聽 If Usar_Autentificacion Then 聽
聽 
聽 聽 ' Id de usuario del servidor Smtp ( en el caso de gmail, debe ser la direcci贸n de correro _ 聽 
聽 聽 聽mas el @gmail.com ) 聽 
聽 聽 Obj_Email.Configuration.Fields.Item _ 聽 
聽 聽 聽 聽 ("http://schemas.microsoft.com/cdo/configuration/sendusername") = Usuario 聽 
聽 
聽 聽 ' Password de la cuenta 聽 
聽 聽 Obj_Email.Configuration.Fields.Item _ 聽 
聽 聽 聽 聽 ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Password 聽 
聽 
聽 聽 ' Indica si se usa SSL para el env铆o. En el caso de Gmail requiere que est茅 en True 聽 
聽 聽 Obj_Email.Configuration.Fields.Item _ 聽 
聽 聽 聽 聽 ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = Usar_SSL 聽 
聽 聽 聽 聽
聽 聽 End If


http://www.recursosvisualbasic.com.ar/htm/trucos-codigofuente-visual-basic/337-enviar-correo-en-vb-con-microsoft-cdo.htm



sas
Benjamin Casarrubias Moreno
Cd. Obreg贸n, Sonora, M茅xico
chino72vale@hotmail.com
Fivewin 24.04, Harbour 3.3, xharbour 1.2.1, Fivelinux, Visual Estudio 2022
Oracle Api Rest, SDK Contpaq, Facturaci贸n Electr贸nica, XML DIOT 2025
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Sending e-mail with CDO and SSL
Posted: Thu Mar 28, 2013 09:43 PM

In the code I supplied, all three of those items are referenced properly.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Sending e-mail with CDO and SSL
Posted: Sun Mar 31, 2013 07:18 PM

Tim,

Are you using the code supplied here?

viewtopic.php?f=3t=15843p=82081hilit=gmail#p82081

Have you checked to see if your firewall is blocking the port?

Have you tried increasing the timeout value?

Regards,
James

&&&

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Sending e-mail with CDO and SSL
Posted: Mon Apr 01, 2013 07:44 PM

James,

Yes, that is where the code is from.

The settings are identical to Outlook, which is working, so the port is not blocked.

The timeout value is set to 30 but the error reports back much more quickly.

The question is, what element returns that error on :Send( )

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Sending e-mail with CDO and SSL
Posted: Mon Apr 01, 2013 09:59 PM

Tim,

I sent a test program to your email. Please let us know if it works for you.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Sending e-mail with CDO and SSL
Posted: Mon Apr 01, 2013 11:09 PM

Tim,

>The settings are identical to Outlook, which is working, so the port is not blocked.

I think this is where the problem may be. You MUST use port 465. Is that the port the Outlook is using? Is that the port your sample code is using? If not, try port 465.

I tried port 25 and it errors out, but port 465 works fine.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Sending e-mail with CDO and SSL
Posted: Tue Apr 02, 2013 12:15 AM

Tim,

May I suggest using a mail object rather than an array--it would be much easier to read.

Instead of:

aTabMail[02]
aTabMail[03]
aTabMail[04]

You would have:

oTabMail:From
oTabMail:To
oTabMail:Subject

It is so much easier to work with.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Sending e-mail with CDO and SSL
Posted: Wed Apr 03, 2013 03:40 PM

See this thread for a solution:

viewtopic.php?f=3t=26019

James

&

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: Sending e-mail with CDO and SSL
Posted: Wed Apr 03, 2013 07:21 PM

To send emails using ssl, at least from xharbour, you must link the open ssl lib: tipssl.lib

On your app directory you need to have these .dlls present:
libeay32.dll
ssleay32.dll

There are a few threads on the xharbour forum explaining how to build the .libs and where to download the .dlls from.

A simpler way to test if you have the open ssl libs linked, is trying to http to an https address. Once everything is in place, you can use xharbour's native emailing funcs.

Hope that helps,

Reinaldo.

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Sending e-mail with CDO and SSL
Posted: Wed Apr 03, 2013 08:28 PM
reinaldocrespo wrote:
There are a few threads on the xharbour forum explaining how to build the .libs and where to download the .dlls from.

A simpler way to test if you have the open ssl libs linked, is trying to http to an https address. Once everything is in place, you can use xharbour's native emailing funcs.


Can you provide a link to the location of the information and DLLs you mentioned?

I seem to remember, when I looked into this before, that you had to purchase some kind of security certificate? I expect this would be for each user?

I'm not sure how you can use FW's native email classes since they don't support SLL thus there are no native settings for SSL. At the least it would seem that you would have to subclass the TSMTP class to add the SLL settings.

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: Sending e-mail with CDO and SSL
Posted: Wed Apr 03, 2013 08:55 PM
download open ssl from:
http://slproweb.com/download/Win32OpenSSL-0_9_8y.exe
http://www.microsoft.com/downloads/deta ... 4B9F2BC1BF
" rel="noopener">
http://slproweb.com/download/Win32OpenSSL-0_9_8y.exe
http://www.microsoft.com/downloads/deta ... 4B9F2BC1BF


Open ssl is an open source project. Nothing to purchase. The web server wishing to have an https address, needs to purchase a security certificate. Not so the user that connectes to it. Email server requiring ssl authentication, must have purchased their security certificate. Otherwise, they could not be offering/requiring ssl connections.

FW TSMTP native email does not send using ssl. You would have to change the class. To send emails using a server that requres ssl authentication, you would have to use xharbour native emaling funcs that inherit from xharbour's Tip class + have the ssl libs linked in. Again, there are a few users on the xharbour's ng that know a lot more than I do. I was helped by Luiz Rafael Culik from Brazil. It took me a while to understand, but since it has been working, I haven't looked at that again. It just works.



Reinaldo.
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Sending e-mail with CDO and SSL
Posted: Thu Apr 04, 2013 01:26 PM
Tim and friends ..

Since I started this thread .. I wanted to make sure that we end it on the solution ..

Tim .. I cut and pasted this solution from your ( other ) thread that spawned from this one .. Please verify this is your solution to implementing CDO and SSl ..

Many thanks!
Rick Lipkin

Code (fw): Select all Collapse
Function CDOSendMail( aTabMail )
    Local oEmailCfg,oEmailMsg

/* Tabmail
01 = MAILSERVER  // A correct mail server address
02 = MAILFROM  // A valid originator of the message
03 = MAILTO  // Who it is being sent to
04 = SUBJECT  // The subect
05 = BODY  // The body in text format
06 = ATTACHMENT  // Attachment(s)
07 = BCC  // Usually NIL  NOT USED
08 = LAUTHORIZATION  // T or F logical for authentication
09 = USERID pour MAILSERVER  // The mail server Username
10 = PW     pour MAILSERVER  // The mail server password
11 = Mail port   defaut = 25  // The port, default is 25, set to 465 for SSL
12 = Mail HTML page  // An HTML page, usually not used
13 = ssl authentification  // T or F logical for SSL
14 = Mail sender  // Mail sender name  NOT USED
15 = Organisation sender  // Organization sender  NOT USED
16 = Host  // Host if needed  NOT USED
*/
    TRY
       oEmailCfg := CREATEOBJECT( "CDO.Configuration" )
      WITH OBJECT  oEmailCfg:Fields
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value :=   TRIM( aTabMail[01] ) //"mail.xxxxxxxx.com"
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value :=  aTabMail[11] // 25
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2   // Remote SMTP = 2, local = 1
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value :=  aTabMail[08] // .T.
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value :=  aTabMail[13]
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := TRIM( aTabMail[09] ) //  "xxanser@xxxxxxxx.com"
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := TRIM( aTabMail[10] ) // "xxxxxx"
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 30
         :Update()
      END WITH
    CATCH oError
      MsgInfo( "Could not create message configuration" + ";"  + ;
             "Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
             "SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
             "OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
             "SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
             "Message: " + oError:Description )
       Return .F.
    END
    oError:=NIL

    TRY
     oEmailMsg := CREATEOBJECT ( "CDO.Message" )
     WITH OBJECT oEmailMsg
        :Configuration =  oEmailCfg
        :From = aTabMail[02] //chr(34)+" Anser K.K. "+chr(34)+ "<anser@xxxxxxxx.com>" // This will be displayed in the From (The email id does not appear)
        :To = TRIM( aTabMail[03] ) // "xxanserkk@xxxxx.com"    // <-----   Place the TO email address
        :Subject = aTabMail[04] // "This is a Tst message"
        :MDNRequested = .T.
        :TextBody =  TRIM( aTabMail[05] )
        IF LEN( aTabMail[06] ) > 0
            For nEle := 1 To Len( aTabMail[06] )
             :AddAttachment( ALLTRIM(aTabMail[06][nEle] )) // := AllTrim( aAttach[ nEle ] )
            Next
        ENDIF
     END WITH
     oEmailMsg:Send( )
    CATCH oError
       
       MsgInfo( "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 )
       Return .F.
   
    END

Return( .t. )