FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bad Email Dreams ...
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Bad Email Dreams ...
Posted: Sat May 12, 2012 02:42 AM
For several years I have used SMTP so my clients can send emails. It works fine for me, and for many others, but on too many, it won't work. My guess is their service provider blocks the response, so the program never actually sends the email.

So, I decided to just insist they have an email client setup, and I would use MAPI.

If I use the code:
ACTION winexec( "rundll32.exe url.dll, FileProtocolHandler mailto:support@masterlinksoftware.com")
It will work fine. The problem is that I want to send attachements and I don't believe this method allows for that possibility.

So I tried the FWH tMail option. I'm using Office Outlook 2010, so when I run it, I get a message that Outlook is not my default email service ( it is ), so it can't run the request.

I've tried all types of SMTP. It just isnt working in all cases. I can't solve the problem because of course it works fine on all my test machines.

Does anyone have suggestions ?
1) How to extend my working line of code to include attachements, or
2) How to get tMail to work with Outlook 2010 ( or is it a Win7 issue ? ).

Thanks

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: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 09:25 AM

MAybe to try See32 library?

We are using this library for so many years and works perfect. We can send attachments.

The user must setup their mail server credentials (Smnp server, username, password, port) and this is it

Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 10:31 AM

Hi Tim,

May be CDOSys could handle it. It's included with every Win since 2000 Server, and works with ssl and attachments, and non convencional account like google or yahoo ones.

Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
鈥淚f you think education is expensive, try ignorance"
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 02:04 PM

Thanks for the responses.

I'm still curious why the tMail option is not working with Office 2010 ( or is it a Windows 7 problem ? ).

Is there a fix ?

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: 302
Joined: Fri Apr 23, 2010 04:30 AM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 04:34 PM

Tim

Cdossys is easy and works fine i can send atachments and html body, i tested with FWH for xHarbour and Harbour compiled with MVC, BCC and Mingw.

Regards,

Nicanor Martinez M.
Auditoria y Sistemas Ltda.
MicroExpress Ltda.
FW + FWH + XHARBOUR + HARBOUR + PELLES C + XDEVSTUDIO + XEDIT + BCC + VC_X86 + VCC_X64 + MINGW + R&R Reports + FastReport + Tdolphin + ADO + MYSQL + MARIADB + ORACLE
nnicanor@yahoo.com
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 06:43 PM

Are there any samples of using cDosSys ? From what I see on the internet searches, it is designed for web based apps.

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: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 07:29 PM
I have had really good luck with a SMTP Component from Ostrosoft. It is free for non-commercial license.
You only need to copy and register 1 dll file.
http://www.ostrosoft.com/OSSMTP6.asp
If you are interested, let me know and I will send or post some sample code. It is really fast and reliable.
Posts: 302
Joined: Fri Apr 23, 2010 04:30 AM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 07:45 PM
Tim,

This is my modified cdosys functions, you may to define a dbf to save config, for config use femail( cAlias ) parameter can be an alias or data object like dolphin query o tdabase object.

use config alias ... new ... shared ......

Femail( "config")

or

use config alias ...... new shared.
database oConfig

Femail( OConfig")

using tdolphin

oConfig := oServer:Query("Select * from config")

Femail( oConfig")

TO send mail use function Envia_Email( cFgAlias, cTo , cBcc, cSubJect, cAttach ) ..



Code (fw): Select all Collapse
#INCLUDE "FIVEWIN.CH"
#include "recursos.ch"
#include "CdoSys.ch"
#include "hbcompat.ch"

#ifndef _CDOSYS_CH
#define _CDOSYS_CH
#define cdoSMTPServer 聽 聽 聽 聽 聽 聽"http://schemas.microsoft.com/cdo/configuration/smtpserver"
#define cdoSMTPServerPort 聽 聽 聽 聽"http://schemas.microsoft.com/cdo/configuration/smtpserverport"
#define cdoSendUsing 聽 聽 聽 聽 聽 聽 "http://schemas.microsoft.com/cdo/configuration/sendusing"
#define cdoSMTPPickupFolder 聽 聽 聽"http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"
#define cdoSMTPAuthenticate 聽 聽 聽"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
#define cdoSendUserName 聽 聽 聽 聽 聽"http://schemas.microsoft.com/cdo/configuration/sendusername"
#define cdoSendPassword 聽 聽 聽 聽 聽"http://schemas.microsoft.com/cdo/configuration/sendpassword"
#define cdoSMTPUseSSL 聽 聽 聽 聽 聽 聽"http://schemas.microsoft.com/cdo/configuration/smtpusessl"
#define cdoSMTPConnectionTimeout "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
#endif
聽//20Us3rP4l3rm011
#define NTRIM(n) 聽 聽( LTrim( Str( n ) ) )

#define WS_3DLOOK 聽4
#define CLR_HBROWN nRGB( 205, 192, 176 )
#define CLR_NBLUE 聽nRGB( 142, 171, 194 )

//----------------------------------------------------------//

FUNCTION str_replace(cString, cFind, cReplace )
Local cStr,nPos,nTot,cToc1,cToc2

聽 nPos := AT( upper(cFind), upper(cString) )
聽 nTot := len( cFind )

聽 if nPos > 0

聽 聽 聽cToc1 := Substr( cString, 1, nPos-1 )
聽 聽 聽cToc2 := Substr( cString, nPos + nTot + 1 )

聽 聽 聽cStr 聽:= cToc1+cReplace+cToc2

聽 else

聽 聽 聽cStr := cString

聽 endif

Return cStr

//--------------------------------------//

Function fEmail_config( cFgAlias )

聽 聽Local oDlg, aCtl[ 22 ], oFont,lOk:=.f.

聽 聽Local cMailServer := PadR( "tuservidordecorreo.com", 60 ), ; 聽 聽 聽 聽 聽 聽 // servidor de correo
聽 聽 聽 聽 聽cFrom 聽 聽 聽 := PadR( "tucuenta@tuservidor.com", 60 ), ; 聽 聽 聽 聽// remitente
聽 聽 聽 聽 聽cTo 聽 聽 聽 聽 := PadR( "", 180 ), ; // destinatario (uno o varios separados con comas)
聽 聽 聽 聽 聽cBCC 聽 聽 聽 聽:= PadR( "", 180 ), ; // copias ocultas a (uno o varios separados con comas)
聽 聽 聽 聽 聽cAttach 聽 聽 := PadR( "", 2048 ), ;// archivo anexo (uno o varios separados con comas)
聽 聽 聽 聽 聽cSubject 聽 聽:= "Informes Vencimiento Documentos "+Dtoc(Date())+" "+time(), ; 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// asunto
聽 聽 聽 聽 聽cBody 聽 聽 聽 := "Notificacion automatica de Vencimientos "+CRLF+CRLF+"Sistema de Control", ; 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 // cuerpo del mensaje
聽 聽 聽 聽 聽nPort 聽 聽 聽 := 25 ,; //465, ; 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// puerto usado por el servidor de correo // 465 si es Gmail
聽 聽 聽 聽 聽cUser 聽 聽 聽 := Space( 60 ), ; 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// nombre de usuario para autenticaci贸n 
聽 聽 聽 聽 聽cPass 聽 聽 聽 := Space( 30 ) 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽// contrase帽a para autenticaci贸n

IF valtype( cFgAlias )=="C"

聽 聽cMailServer := ( cFgAlias )->CSERVER
聽 聽cFrom 聽 聽 聽 := ( cFgAlias )->CFROM
聽 聽cTo 聽 聽 聽 聽 := ( cFgAlias )->CTO
聽 聽cBCC 聽 聽 聽 聽:= ( cFgAlias )->CCC
聽 聽cSubJect 聽 聽:= ( cFgAlias )->CSUBJECT
聽 聽nPort 聽 聽 聽 := ( cFgAlias )->NPORT
聽 聽cUser 聽 聽 聽 := ( cFgAlias )->CUSER
聽 聽cPass 聽 聽 聽 := ( cFgAlias )->CPASS
聽 聽cBody 聽 聽 聽 := ( cFgAlias )->CBODY

Else

聽 聽cMailServer := cFgAlias:CSERVER
聽 聽cFrom 聽 聽 聽 := cFgAlias:CFROM
聽 聽cTo 聽 聽 聽 聽 := cFgAlias:CTO
聽 聽cBCC 聽 聽 聽 聽:= cFgAlias:CCC
聽 聽cSubJect 聽 聽:= cFgAlias:CSUBJECT
聽 聽nPort 聽 聽 聽 := cFgAlias:NPORT
聽 聽cUser 聽 聽 聽 := cFgAlias:CUSER
聽 聽cPass 聽 聽 聽 := cFgAlias:CPASS

ENDIF


// 聽 DEFINE FONT oFont NAME "Arial" SIZE 0, -16

聽 聽 oFont := TFont():New( GetDefaultFontName(), 0, GetDefaultFontHeight(),, )

聽 聽DEFINE DIALOG oDlg FROM 0, 0 TO 455, 703 PIXEL FONT oFontb ;
聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN ;
聽 聽 聽 聽 聽 TITLE "Configuracion Servidor de Envio de Informes para empresas" ;
聽 聽 聽 聽 聽 STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, WS_3DLOOK )

聽 聽@ 10, 聽5 SAY aCtl[ 1 ] PROMPT "Servidor de Correo:" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN SIZE 70, 11 PIXEL

聽 聽@ 10, 80 GET aCtl[ 2 ] VAR cMailServer OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont 聽UPDATE 聽PICTURE "@K" ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 206, 11 PIXEL

聽 聽@ 10,294 SAY aCtl[ 3 ] PROMPT "Puerto:" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN SIZE 30, 11 PIXEL

聽 聽@ 10,320 GET aCtl[ 4 ] VAR nPort OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont 聽UPDATE 聽PICTURE "@K ####" ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 24, 11 PIXEL

聽 聽@ 24, 聽5 SAY aCtl[ 5 ] PROMPT "Remitente:" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN SIZE 70, 11 PIXEL

聽 聽@ 24, 80 GET aCtl[ 6 ] VAR cFrom OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont 聽UPDATE 聽PICTURE "@K" ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 264, 11 PIXEL

聽 聽@ 39, 聽5 SAY aCtl[ 7 ] PROMPT "Destinatario:" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN SIZE 70, 11 PIXEL

聽 聽@ 39, 80 GET aCtl[ 8 ] VAR cTo OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont 聽UPDATE 聽PICTURE "@K" ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 264, 11 PIXEL

聽 聽@ 54, 聽5 SAY aCtl[ 9 ] PROMPT "Copia para:" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN SIZE 70, 11 PIXEL

聽 聽@ 54, 80 GET aCtl[ 10 ] VAR cBCC OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont 聽UPDATE 聽PICTURE "@K" ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 264, 11 PIXEL

聽 聽@ 69, 聽5 SAY aCtl[ 11 ] PROMPT "Adjuntar:" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN SIZE 70, 11 PIXEL

聽 聽@ 69, 80 GET aCtl[ 12 ] VAR cAttach OF oDlg 聽PICTURE "@K" ;
聽 聽 聽 聽 聽 聽 FONT oFont 聽UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 253, 11 PIXEL // ACTION fAddAttach( aCtl[ 12 ] ) ; // descomentar para FWH 8.12 o posterior

聽 聽@ 69,333 BUTTON "..." OF oDlg SIZE 10, 10 PIXEL ACTION fAddAttach( aCtl[ 12 ] )

聽 聽@ 84, 聽5 SAY aCtl[ 13 ] PROMPT "Asunto:" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN SIZE 70, 11 PIXEL

聽 聽@ 84, 80 GET aCtl[ 14 ] VAR cSubject OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont 聽UPDATE PICTURE "@K" ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 264, 11 PIXEL

聽 聽@ 99, 聽5 SAY aCtl[ 15 ] PROMPT "Autenticaci贸n: Usuario:" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN SIZE 80, 11 PIXEL

聽 聽@ 99, 87 GET aCtl[ 16 ] VAR cUser OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont 聽UPDATE PICTURE "@K" ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 118, 11 PIXEL

聽 聽@ 99,213 SAY aCtl[ 17 ] PROMPT "Contrase帽a:" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_HBROWN SIZE 44, 11 PIXEL

聽 聽@ 99,259 GET aCtl[ 18 ] VAR cPass OF oDlg PASSWORD ;
聽 聽 聽 聽 聽 聽 FONT oFont 聽UPDATE 聽PICTURE "@K";
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 85, 11 PIXEL

聽 聽@118, 聽6 SAY aCtl[ 19 ] PROMPT "Cuerpo del mensaje" OF oDlg ;
聽 聽 聽 聽 聽 聽 SIZE 100, 11 PIXEL ;
聽 聽 聽 聽 聽 聽 FONT oFont COLORS CLR_BLUE, CLR_HBROWN

聽 聽@126, 10 GET aCtl[ 20 ] VAR cBody OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont MULTILINE 聽UPDATE ;
聽 聽 聽 聽 聽 聽 COLORS CLR_BLUE, CLR_WHITE SIZE 330, 72 PIXEL

聽 聽@208,213 BUTTON aCtl[ 21 ] PROMPT "&Grabar" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont SIZE 53, 16 PIXEL 聽;
聽 聽 聽 聽 聽 聽 ACTION ( lok:=.t.,oDlg:End() )

聽 聽@208,292 BUTTON aCtl[ 22 ] PROMPT "&Salir" OF oDlg ;
聽 聽 聽 聽 聽 聽 FONT oFont SIZE 53, 16 PIXEL ACTION oDlg:End()

聽 聽ACTIVATE DIALOG oDlg CENTERED ;
聽 聽 聽 聽 聽 聽 VALID ( oFont:End(), .T. )

聽 聽IF lok == .t.

聽 聽 聽IF valtype( cFgAlias ) == "C"

聽 聽 聽 ( cFgAlias )->( NET_READ() )

聽 聽 聽 ( cFgAlias )->CSERVER 聽:= cMailServer
聽 聽 聽 ( cFgAlias )->CFROM 聽 聽:= cFrom
聽 聽 聽 ( cFgAlias )->CTO 聽 聽 聽:= cTo
聽 聽 聽 ( cFgAlias )->CCC 聽 聽 聽:= cBCC
聽 聽 聽 ( cFgAlias )->CSUBJECT := cSubJect
聽 聽 聽 ( cFgAlias )->NPORT 聽 聽:= nPort
聽 聽 聽 ( cFgAlias )->CUSER 聽 聽:= cUser
聽 聽 聽 ( cFgAlias )->CPASS 聽 聽:= cPass
聽 聽 聽 ( cFgAlias )->CBODY 聽 聽:= cBody

聽 聽 聽 ( cFgAlias )->( DBRUNLOCK() )

聽 聽 聽ELSE

聽 聽 聽 聽cFgAlias:CSERVER := cMailServer
聽 聽 聽 聽cFgAlias:CFROM 聽 := cFrom
聽 聽 聽 聽cFgAlias:CTO 聽 聽 := cTo
聽 聽 聽 聽cFgAlias:CCC 聽 聽 := cBCC
聽 聽 聽 聽cFgAlias:CSUBJECT:= cSubJect
聽 聽 聽 聽cFgAlias:NPORT 聽 := nPort
聽 聽 聽 聽cFgAlias:CUSER 聽 := cUser
聽 聽 聽 聽cFgAlias:CPASS 聽 := cPass
聽 聽 聽 聽cFgAlias:CBODY 聽 := cBody

聽 聽 聽 聽cFgAlias:Save()

聽 聽 聽Endif

聽 聽 聽if msgnoyes("Desea Comprobar el envio ahora ?")

聽 聽 聽 聽 聽 聽 聽 Envia_Email( cFgAlias, cTo , cBcc, cSubJect, cAttach )

聽 聽 聽 聽 聽//fSendMail( cMailServer, cFrom, cTo, cSubject, cBody, cAttach, cBCC, cUser, cPass, nPort )

聽 聽 聽Endif


聽 聽 ENDIF

Return Nil

//--------------------------------------------------------------------------------------------//

Function Envia_Email( cFgAlias, cTo1, cBcc1, cSubject1, cAttach1, cBody1,cDatos )

Local cMailServer,;
聽 聽 聽 cFrom 聽 聽 聽,;
聽 聽 聽 cTo 聽 聽 聽 聽,;
聽 聽 聽 cBCC 聽 聽 聽 ,;
聽 聽 聽 cSubJect 聽 ,;
聽 聽 聽 nPort 聽 聽 聽,;
聽 聽 聽 cUser 聽 聽 聽,;
聽 聽 聽 cPass 聽 聽 聽,;
聽 聽 聽 cBody

聽 聽 IF valtype( cFgAlias ) == "C"

聽 聽 聽 cMailServer := ( cFgAlias )->CSERVER
聽 聽 聽 cFrom 聽 聽 聽 := ( cFgAlias )->CFROM
聽 聽 聽 cTo 聽 聽 聽 聽 := ( cFgAlias )->CTO
聽 聽 聽 cBCC 聽 聽 聽 聽:= ( cFgAlias )->CCC
聽 聽 聽 cSubJect 聽 聽:= ( cFgAlias )->CSUBJECT
聽 聽 聽 nPort 聽 聽 聽 := ( cFgAlias )->NPORT
聽 聽 聽 cUser 聽 聽 聽 := ( cFgAlias )->CUSER
聽 聽 聽 cPass 聽 聽 聽 := ( cFgAlias )->CPASS
聽 聽 聽 cBody 聽 聽 聽 := ( cFgAlias )->CBODY

聽 聽else

聽 聽 聽 cMailServer := cFgAlias:CSERVER
聽 聽 聽 cFrom 聽 聽 聽 := cFgAlias:CFROM
聽 聽 聽 cTo 聽 聽 聽 聽 := cFgAlias:CTO
聽 聽 聽 cBCC 聽 聽 聽 聽:= cFgAlias:CCC
聽 聽 聽 cSubJect 聽 聽:= cFgAlias:CSUBJECT
聽 聽 聽 nPort 聽 聽 聽 := cFgAlias:NPORT
聽 聽 聽 cUser 聽 聽 聽 := cFgAlias:CUSER
聽 聽 聽 cPass 聽 聽 聽 := cFgAlias:CPASS
聽 聽 聽 cBody 聽 聽 聽 := cFgAlias:CBODY

聽 聽ENDIF

聽 聽 聽DEFAULT cTo1 聽 聽 聽:= cTo
聽 聽 聽DEFAULT cSubject1 := cSubject
聽 聽 聽DEFAULT cBody1 聽 聽:= cBody
聽 聽 聽DEFAULT cAttach1 聽:= ""
聽 聽 聽 DEFAULT cBcc1 聽 聽 := cBcc

聽 聽 聽fSendMail( cMailServer, cFrom, cTo1, cSubject1, cBody1, cAttach1, cBCC1, cUser, cPass, nPort, cDatos )

Return

//---------------------------------------------------------------------------------------------//

Function fSendMail( cMailServer, cFrom, cTo, cSubject, cBody, cAttach, cBCC, cUser, cPass, nPort, cDatos )

聽 聽Local oCfg, oMsg, oError, nEle, cToken, ;
聽 聽 聽 聽 聽aAttach 聽:= {}, ;
聽 聽 聽 聽 聽lAuth 聽 聽:= ! Empty( cUser ) .and. ! Empty( cPass ), ;
聽 聽 聽 聽 聽nSendOpt := 2 聽 // send using: 1 = pickup folder 聽2 = port

聽 聽Default nPort 聽 聽:= 25, ;
聽 聽 聽 聽 聽 聽cSubject := "", ;
聽 聽 聽 聽 聽 聽cBody 聽 聽:= "", ;
聽 聽 聽 聽 聽 聽 聽 cDatos 聽 := "Sin datos que mostrar",;
聽 聽 聽 聽 聽 聽 聽 cBcc 聽 聽 :="",;
聽 聽 聽 聽 聽 聽 聽 cUser 聽 聽:="",;
聽 聽 聽 聽 聽 聽 聽 cPass 聽 聽:=""


聽 聽cBody := str_replace( cBody, "\DATOS\", cDatos )

聽 聽If "GMAIL.COM" $ Upper( cMailServer ) .and. ( Empty( cUser ) .or. Empty( cPass ) )
聽 聽 聽 MsgStop( "Con GMail son requeridos nombre de usuario y contrase帽a", "Atenci贸n" )
聽 聽 聽 Return Nil
聽 聽EndIf

聽 聽CursorWait()

聽 聽nEle := 1

聽 聽While ! Empty( cToken := StrToken( cAttach, nEle++, "," ) )
聽 聽 聽 AAdd( aAttach, cToken )
聽 聽EndDo

聽 聽Try
聽 聽 聽 oCfg := CreateObject( "CDO.Configuration" )

聽 聽 聽 With Object oCfg:Fields
聽 聽 聽 聽 聽:Item( cdoSMTPServer ):Value 聽 聽 := Trim( cMailServer )
聽 聽 聽 聽 聽:Item( cdoSMTPServerPort ):Value := nPort
聽 聽 聽 聽 聽:Item( cdoSendUsing ):Value 聽 聽 聽:= nSendOpt

聽 聽 聽 聽 聽If lAuth
聽 聽 聽 聽 聽 聽 :Item( cdoSMTPAuthenticate ):Value := 1
聽 聽 聽 聽 聽 聽 :Item( cdoSendUserName ):Value 聽 聽 := Trim( cUser )
聽 聽 聽 聽 聽 聽 :Item( cdoSendPassword ):Value 聽 聽 := Trim( cPass )
聽 聽 聽 聽 聽 聽 :Item( cdoSMTPUseSSL ):Value 聽 聽 聽 := 1
聽 聽 聽 聽 聽EndIf

聽 聽 聽 聽 聽:Update()

聽 聽 聽 End With

聽 聽 聽 oMsg := CreateObject( "CDO.Message" )

聽 聽 聽 With Object oMsg
聽 聽 聽 聽 聽:Configuration := oCfg
聽 聽 聽 聽 聽:From 聽 聽 聽 聽 聽:= Trim( cFrom )
聽 聽 聽 聽 聽:To 聽 聽 聽 聽 聽 聽:= Trim( cTo )
聽 聽 聽 聽 聽:Subject 聽 聽 聽 := Trim( cSubject )
聽 聽 聽 聽 聽:TextBody 聽 聽 聽:= Trim( cBody )
聽 聽 聽 聽 聽//:MDNRequested 聽:= .T. 聽// confirmacion de recibido
聽 聽 聽 聽 聽//:HTMLBody 聽 聽 聽:= strHTML

聽 聽 聽 聽 聽For nEle := 1 To Len( aAttach )
聽 聽 聽 聽 聽 聽 :AddAttachment( AllTrim( aAttach[ nEle ] ) ) // := AllTrim( aAttach[ nEle ] )
聽 聽 聽 聽 聽Next

聽 聽 聽 聽 聽If ! Empty( cBCC )
聽 聽 聽 聽 聽 聽 :BCC := Trim( cBCC )
聽 聽 聽 聽 聽EndIf

聽 聽 聽 聽 聽:Send()
聽 聽 聽 End With

聽 聽Catch oError

聽 聽 聽 CursorArrow()

聽 聽 聽 cErrores:= 聽"No se pudo enviar el mensaje" + CRLF 聽+ "Error: " + cValToChar( oError:GenCode) + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽"SubC: " + cValToChar( oError:SubCode ) + CRLF + "OSCode: " + cValToChar( oError:OsCode ) + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽"SubSystem: " + cValToChar( oError:SubSystem ) + CRLF + "Mensaje: " + oError:Description +" "+ if( ! Empty( oError:FileName ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ": " + oError:FileName 聽 ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 if( !Empty( oError:Operation ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ": " + oError:Operation 聽 ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "" ) )+CRLF

聽 聽 聽 n := 2 聽 聽// we don't disscard any info again !

聽 聽 聽 while ( n < 74 )
聽 聽 聽 聽 聽 if ! Empty( ProcName( n ) )
聽 聽 聽 聽 聽 聽 聽cErrores := CRLF+cErrores+" 聽 Called from: " + ProcFile( n ) + " => " + Trim( ProcName( n ) ) + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"(" + NTRIM( ProcLine( n ) ) + ")"

聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 n++
聽 聽 聽 end

聽 聽 聽 ??? cErrores

聽 聽 聽 oCfg := Nil
聽 聽 聽 oMsg := Nil
聽 聽 聽 Return Nil

聽 聽End Try

聽 聽oCfg := Nil
聽 聽oMsg := Nil
聽 聽SndPlaySound( GetWinDir() + "\media\Tada.wav", 0 )
聽 聽CursorArrow()

Return Nil

//---------------------------------------------------------------------------------------------//

Static Function fAddAttach( oGet )

聽 聽Local cFile, ;
聽 聽 聽 聽 聽cAttach := oGet:VarGet()

聽 聽cFile := cGetFile( "*.*", "Selecciona el archivo" )

聽 聽If ! Empty( cFile )
聽 聽 聽 cAttach := Lower( PadR( AllTrim( cAttach ) + If( ! Empty( cAttach ), ",", "" ) + AllTrim( cFile ), 2048 ) )
聽 聽EndIf

聽 聽oGet:cText( cAttach )

Return Nil

//-----------------------------------------------------------------------------------------------//
Nicanor Martinez M.
Auditoria y Sistemas Ltda.
MicroExpress Ltda.
FW + FWH + XHARBOUR + HARBOUR + PELLES C + XDEVSTUDIO + XEDIT + BCC + VC_X86 + VCC_X64 + MINGW + R&R Reports + FastReport + Tdolphin + ADO + MYSQL + MARIADB + ORACLE
nnicanor@yahoo.com
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 07:50 PM
If you are using Outlook 2007 or later then CDO does not get installed automatically. You have to install it as a stand alone product.
This page may help. http://j-integra.intrinsyc.com/support/kb/article.aspx?id=113792
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 07:51 PM

Nicanor,

I will try it but my concern is the SMTP protocal. It works fine for me here, but fails on some of my clients systems. That is the problem I am fighting.

Gale, its Free for NON-COMMERCIAL use but my application is being sold commercially.

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: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 08:05 PM

Gale,

That download requires Outlook ( Office ) 2007 and will not work with 2010. It could be "tricked" but Microsoft does not recommend it.

Its interesting how MAILTO will trigger the MAPI Outlook client without a problem, but it, of course, doesn't support attachments.
I need a solution that works for all versions of Outlook, or another email client.

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: 302
Joined: Fri Apr 23, 2010 04:30 AM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 09:04 PM

Tim i am using cdossys with an reserved account in my company server or an autenticated account with gmail an no problem.

Regards,

Nicanor Martinez M.
Auditoria y Sistemas Ltda.
MicroExpress Ltda.
FW + FWH + XHARBOUR + HARBOUR + PELLES C + XDEVSTUDIO + XEDIT + BCC + VC_X86 + VCC_X64 + MINGW + R&R Reports + FastReport + Tdolphin + ADO + MYSQL + MARIADB + ORACLE
nnicanor@yahoo.com
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 09:15 PM

I think the problem is with our service providers. I believe they like to do data mining on all emails going through their system, so they block direct connections to other servers. Some providers have an alternative port that allows us to bypass it, but others I believe block the return even on the alternate port. Consequently we get no response from the server ( some locations ) and the email hangs up.

In other cases, I believe the malware software is not properly set, but I don't have control over this.

Thats why MAPI seems to be a better option, and also the emails are saved both ways, but newer versions of Office do not behave well with it.

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: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 09:30 PM
If you are using Outlook 2010 you can use the Outlook object model directly . The only problem with that is the security pop-up. You can get a free utility (mapilabs) that can bypass the security pop-up, but the Outlook object model is much slower than other approaches.

Quick example without error checking.
Code (fw): Select all Collapse
#define olMailItem 0 聽// Mail object
聽 聽 聽 oOutlook = CREATEOBJECT( "Outlook.Application" )
聽 聽 聽 oMail = oOutlook:CreateItem( olMailItem )
聽 聽 聽 oMail:Recipients:Add( <!-- e --><a href="mailto:'test@mycompany.com">'test@mycompany.com</a><!-- e -->' )
聽 聽 聽 oMail:Attachments:Add( 聽"c:\xharbour\test.htm" )
聽 聽 聽 oMail:Subject = 'Hello'

聽 聽 聽 // oMail:Body = "This is a test." // Text only body
聽 聽 聽 oMail:HTMLBody = MEMOREAD( "c:\xharbour\test.htm" )
聽 聽 聽 oMail:Display = .T.
聽 聽 聽 oMail:send()
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Bad Email Dreams ...
Posted: Mon May 14, 2012 10:57 PM

Gale your code generates:

Error description: Error Outlook.Application:CREATEITEM:ATTACHMENTS/87 E_INVALIDARG: ADD

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