SEND EMAIL

Re: SEND EMAIL

Postby James Bott » Sun Mar 24, 2013 6:58 pm

Tim,

I would sure love an SMTP system that works . Sadly, the native system to FWH does not support SSL either, nor does it support attachments.


FWH's TSMTP class does support attachments. There are two issues to keep in mind. First, the attachment name has to include the full path and drive letter. Second, if you are using a temp file as an attachment, you have to put in a delay before deleting the temp file or it may get deleted before it is mailed. If you are still having problems with attachments, then please post your code here and maybe I can find the problem.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: SEND EMAIL

Postby TimStone » Mon Mar 25, 2013 5:11 pm

I've had attachments all along but I'm using an updated version of tSMTP. The last time I looked, that was still not part of the one included in the libraries.

However, none of those support SSL.

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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: SEND EMAIL

Postby Enrico Maria Giordano » Wed Apr 03, 2013 5:19 pm

Enrico Maria Giordano wrote:I'm getting erratic errors from Send() method that is not replicable. Anyone got that error and found a way to solve the problem?

EMG


Any suggestions? :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: SEND EMAIL

Postby James Bott » Wed Apr 03, 2013 6:01 pm

Enrico,

I have not seen such a problem. Are you getting error messages? Or, do you mean that some PCs have errors and some do not?

It could be the server. I have occasional server problems even with big email systems like Hotmail, AOL, etc. even with Outlook Express.

Perhaps you could put in a routine so that if it errors out when attempting to send, it tries again in 10 seconds--maybe a couple of times.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: SEND EMAIL

Postby Enrico Maria Giordano » Wed Apr 03, 2013 6:17 pm

James,

James Bott wrote:Enrico,

I have not seen such a problem. Are you getting error messages?


It seems not.

James Bott wrote:Or, do you mean that some PCs have errors and some do not?


No, the behavior is erratic on the same PC.

James Bott wrote:It could be the server. I have occasional server problems even with big email systems like Hotmail, AOL, etc. even with Outlook Express.

Perhaps you could put in a routine so that if it errors out when attempting to send, it tries again in 10 seconds--maybe a couple of times.

Regards,
James


Thank you, I will try.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: SEND EMAIL

Postby reinaldocrespo » Wed Apr 03, 2013 7:11 pm

Enrico;

Are you sending multiple emails?

I'm using tsmtp on one of my apps quite a bit. Its working quite well for me. This particular app sends over 300 emails per day with .zip attachments. Remember TSMTP does not do SSL. Show me the code. Maybe I can help.



Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: SEND EMAIL

Postby Enrico Maria Giordano » Wed Apr 03, 2013 8:14 pm

Reinaldo,

reinaldocrespo wrote:Enrico;

Are you sending multiple emails?


Yes, but the erratic behavior is the same with a single email.

reinaldocrespo wrote:I'm using tsmtp on one of my apps quite a bit. Its working quite well for me. This particular app sends over 300 emails per day with .zip attachments. Remember TSMTP does not do SSL. Show me the code. Maybe I can help.


The code is the one already reported here and in other threads (CDOSYS).

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: SEND EMAIL

Postby reinaldocrespo » Wed Apr 03, 2013 8:31 pm

CDOSYS and TSMTP are not the same. I have been using TSMTP. I once tried CDOSYS, but had sporadic errors and was never able to figure out, or did not spend enough time debuggin.

Here is my code using TSMTP, there are references to other objects, but I'm sure you can follow the code:

Code: Select all  Expand view

//-----------------------------------------------------------------------
METHOD SendViaEMail( oDbf, oPthRep ) CLASS TMpMailApp
   LOCAL aEmails := HB_ATOKENS( oDbf:Send_To, iif( ";" $ oDbf:Send_To, ";", "," ) )
   LOCAL oDoc      := ::oProcess:Getodbf( "doctors" )
   LOCAL cZipFile  := Temp_Name( "zip" )
   LOCAL cPass, oMail, oTmp
   LOCAL aFiles    := { oPthRep:cPdfFile }
   LOCAL cPathNo := oDbf:PathNo
   LOCAL nQueue  := oDbf:Queue
   LOCAL cSendTo := oDbf:Send_To

   IF oPthRep:isJpg  ;AADD( aFiles, oPthRep:cJpgFile )  ;ENDIF
   IF oPthRep:IsTiff ;AADD( aFiles, oPthRep:cTifFile)   ;ENDIF
   IF oPthRep:isHtml ;AADD( aFiles, oPthRep:cHtmlFile ) ;ENDIF
   IF oPthRep:isRtf  ;AADD( aFiles, oPthRep:cRtfFile )  ;ENDIF

   AEVAL( aEmails, { |e,n| aEmails[ n ] := ALLTRIM( e ) } )

   oDoc:Seek( oDbf:Doc_id )   ;iif( oDoc:Found(), oDoc:Load(), oDoc:Blank() )

   cPass   := ALLTRIM( IIF( oDoc:fieldexist( "password" ) .AND. ;
                     !EMPTY( oDoc:VarPassword ), ;
                     oDoc:VarPassword, oDbf:Doc_id ) )

   IF !hb_zipFile( cZipFile, aFiles, 9,,.t., cPass, .f., .f., .t.  )

      AEVAL( aFiles, { |e| fErase( e ) } )
      ferase( cZipFile )
      Logfile( "PtheMailsErrors.log", { "Error Creating .zip for case:", oDbf:PathNo } )

      RETURN NIL

   ENDIF

   oMail := TMySmtp():New( ::cIp, ::nPort, ::lAuth, ::cUserName, ::cUserPass )
   oMail:cReplyTo := ::cSender
   oMail:nGMT := TimeZone() //-5   // Atlantic Standard Time (GMT -05:00)

   oMail:aAttachments := aFiles    //save file names to erase later
   
   oMail:oSocket:lDebug := ::lDebug
   oMail:oSocket:cLogFile := "smtp.log"
   oMail:nDelay := ::nDelay

   oMail:bConnecting   := { || iif( oMail:oSocket:lDebug,;
      logfile( oMail:oSocket:cLogFile, { cPathNo, "Connecting to SMTP server " + ::cSmtpServer } ), ) }

   oMail:bConnected   := { || iif( oMail:oSocket:lDebug, ;
      logfile( oMail:oSocket:cLogFile, { cpathNo, "Sending eMail Via " + ::cSmtpServer } ), ) }

   oMail:bDone := { || MailWasSent( cPathNo, nQueue, cSendto ),;
            LogSuccessIntoAuditLog( cPathNo, cSendto ),;
            fErase( cZipFile ),;
            AEVAL( oMail:aAttachments, { |e| ferase( e ) } ),;
            oMail:End(), ;
            oMail := Nil,;
            AEVAL( aFiles, { |e| fErase( e ) } ) }

   oMail:bFailure := { || IncAttempts( cPathNo, nQueue, cSendto ) ,;
            fErase( cZipFile ),;
            AEVAL( oMail:aAttachments, { |e| ferase( e ) } ),;
            iif( oMail != Nil .and. oMail:oSocket:lDebug, ;
                  logfile( oMail:oSocket:cLogFile, { "Failure to send email" } ), ),;
            iif( oMail != Nil, ( oMail:end(), oMail := Nil ), ) }


   oMail:SendMail( ::cSender, aEmails,                   ;
      "Pathology report attached intended for " +                                              ;
        alltrim( StrCapFirst( oDoc:Last ) ) + ", " + alltrim( StrCapFirst( oDoc:First ) )+      ;
        ".  Please use your password to open zipped file." + Chr( 13 ) + Chr( 12 ) +             ;
      "The information contained in this e-mail is privileged and confidential, intended only for the use of "+;
      "the individual or entity named above.  If the reader of this message is not the intended recipient, "+;
      "you are hereby notified that any dissemination, distribution or copy of this information is strictly "+;
      "prohibited.",    ;// Msg Text
      "Pathology Report", ;   // Subject
      { cZipFile },,, .t.  ) // attached files

RETURN NIL

 


That is working quite well for me. Hope it helps,


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: SEND EMAIL

Postby James Bott » Wed Apr 03, 2013 8:38 pm

Enrico,

Ah, I thought you were using the FW native TSMTP class.

Is it erroring out during configuration or during sending? If during sending, you might try adding a sysrefresh() just after the :Update() during the configuration.

How often is it erroring out? Once every ten times or? When it errors out, and you immediately try resending the same email does it go through?

If you send the same email 10-20 times does it go sometimes and not others?

Is it only erroring out when there is an attachment?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: SEND EMAIL

Postby Enrico Maria Giordano » Wed Apr 03, 2013 8:42 pm

Reinaldo,

thank you, I'll try it.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: SEND EMAIL

Postby Enrico Maria Giordano » Wed Apr 03, 2013 8:50 pm

James,

James Bott wrote:Enrico,

Ah, I thought you were using the FW native TSMTP class.

Is it erroring out during configuration or during sending?


During sending.

James Bott wrote:If during sending, you might try adding a sysrefresh() just after the :Update() during the configuration.


Great suggestion! I'm going to try it, thank you!

James Bott wrote:How often is it erroring out? Once every ten times or?


Hard to say... :-(

James Bott wrote:When it errors out, and you immediately try resending the same email does it go through?


Yes.

James Bott wrote:If you send the same email 10-20 times does it go sometimes and not others?


Yes.

James Bott wrote:Is it only erroring out when there is an attachment?


I tested it with attachments.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: SEND EMAIL

Postby James Bott » Thu Apr 04, 2013 12:39 am

Enrico,

OK, I think my original suggestion will be the best solution. When it errors, trap the error, and do a repeat send a few times until it goes through, or completes the cycle. Once it is automated, most of the emails will probably be sent without human intervention.

I did this type of thing a long time ago when I was sending automated faxes. It worked great.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: SEND EMAIL

Postby Enrico Maria Giordano » Thu Apr 04, 2013 12:45 pm

James Bott wrote:Enrico,

OK, I think my original suggestion will be the best solution. When it errors, trap the error, and do a repeat send a few times until it goes through, or completes the cycle. Once it is automated, most of the emails will probably be sent without human intervention.

I did this type of thing a long time ago when I was sending automated faxes. It worked great.

James


I don't like it very much because I still don't know what the error is so I can't trap it.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: SEND EMAIL

Postby ADutheil » Thu Apr 04, 2013 1:25 pm

Enrico,

did you try hb_SendMail function? I´ve been successfully sending mails with attachments from gmail accounts (TLS/SSL) for a while now.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: SEND EMAIL

Postby Enrico Maria Giordano » Thu Apr 04, 2013 1:28 pm

Yes, I tried it but I found it very slow.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 88 guests