Error sending an email

241 views
Skip to first unread message

Antonio Cardinaux

unread,
May 28, 2024, 11:15:33 AMMay 28
to Harbour Users
I wanted to try this function that I saw on the forum

// *---------------------------------------------------------------------------*
//  Send e-mail
//  Using: CDO Sys
// *---------------------------------------------------------------------------*
FUNCTION MR_Send_Cdo_Mail( cFile )

   LOCAL cServer := 'smtp.gmail.com'
   LOCAL nPort := 465
   LOCAL cFrom := 'a...@gmail.com'
   LOCAL xTo := 'to_???__@gmail.com'
   LOCAL cBody := 'Body: Simple eMail Test' + hb_OSNEWLINE() + hb_OSNEWLINE() + 'Line Four'
   LOCAL cSubject := 'Simple eMail Test'
   LOCAL cUser := cFrom
   LOCAL cPass := '12345678'
   LOCAL lRet := .T.
   LOCAL oConfig
   LOCAL oMail__
   LOCAL oErr
   
   BEGIN SEQUENCE WITH {| oErr | Break( oErr ) }

      oConfig := CREATEOBJECT( "CDO.Configuration" )
      WITH OBJECT oConfig:Fields
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" )      :Value := cServer
         :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 := 1
         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" )      :Value := 1
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" )    :Value := cFrom
         :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" )    :Value := cPass
         :Update()
      END WITH

      oMail__ := CREATEOBJECT ( "CDO.Message" )
      WITH OBJECT oMail__
         :Configuration := oConfig
         :From          := cFrom
         :To            := xTo
         :Subject       := cSubject
         :TextBody      := cBody
         IF HB_ISSTRING( cFile )
            IF hb_FileExists( cFile )
               :AddAttachment( cFile )
            ENDIF
         ENDIF
         :Send()
      ENDWITH

   RECOVER USING oErr

      MSGINFO( "Error....: " + TRANSFORM(oErr:GenCode, NIL)   + hb_OSNEWLINE() + ;
                "SubCode..: " + TRANSFORM(oErr:SubCode, NIL)   + hb_OSNEWLINE() + ;
                "OS_Code..: " + TRANSFORM(oErr:OsCode, NIL)    + hb_OSNEWLINE() + ;
                "SubSystem: " + TRANSFORM(oErr:SubSystem, NIL) + hb_OSNEWLINE() + ;
                "Mensagem.: " + oErr:Description )
      lRet := .F.

   END SEQUENCE

RETUR ( lRet )

But I get the error message that I attached. What is this error due to?
Error envio de correo harbour.JPG

arielso...@gmail.com

unread,
May 28, 2024, 11:57:43 AMMay 28
to harbou...@googlegroups.com

Try

 

     loCfg := CREATEOBJECT( "CDO.Configuration" )

      WITH OBJECT loCfg:Fields

         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver"):Value        := "mail.demo.mx"

         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport"):Value    := 465

         :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing"):Value         := 2

         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := .T.  // here

         :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl"):Value        := .T.        // here

         :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername"):Value      := "cf...@demo.mx"

         :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword"):Value      := "xxxxxxxxxxxxxxxxx"

         :Update()

      END WITH

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/2d12769b-c414-4ee8-a681-7608e5f9ab41n%40googlegroups.com.

Antonio Cardinaux

unread,
May 31, 2024, 8:27:11 AMMay 31
to Harbour Users
There I made the modifications that you suggested, but now it gives me the error that I attached
Error de transporte en la conexión al servidor.JPG

diego...@gmail.com

unread,
May 31, 2024, 10:38:53 AMMay 31
to Harbour Users

Antonio Cardinaux

unread,
Jun 3, 2024, 11:53:13 AMJun 3
to Harbour Users
Llegué a la parte de seguridad, pero no veo que esté "Permitir el acceso de aplicaciones poco seguras", hay una parte que dice "Tus conexiones con aplicaciones y servicios de terceros", pero no veo cómo se puede agregar alguna aplicación ahi.

diego...@gmail.com

unread,
Jun 3, 2024, 1:56:00 PMJun 3
to Harbour Users
Me parece que Google ya no permite o no permitira( dependiendo de la antiguedad de la cta) utilizar gmail u otro servicio cuando no se utilice OAUTH. Busca esto en linea ya que tal vez sea este el problema. 

jparada

unread,
Jun 4, 2024, 10:32:40 AMJun 4
to Harbour Users
Reply all
Reply to author
Forward
0 new messages