FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Dll para leer pop3 gmail
Posts: 120
Joined: Wed Mar 11, 2009 07:32 PM
Dll para leer pop3 gmail
Posted: Sat Jun 06, 2015 04:40 AM
Hola buenas tardes

le anexo una dll para leer correos pop3
la saque de http://hpop.sourceforge.net/

lo pueden bajar en http://www.eleben.com.mx/gmail.zip

ejemplo de uso

Code (fw): Select all Collapse
// Pruebas
// benjamin casarrubias moreno
// <!-- e --><a href="mailto:chino72vale@hotmail.com">chino72vale@hotmail.com</a><!-- e -->
// 05/06/2015
#include "FiveWin.ch"


static lsigue, nomdire, osrv, odlg, obenito, olbx


Function main()
LOCAL I, ncorreos
local n:=0, y
local cadjuntos:={}
local oeleben

set epoch to 1990
set century on
set date italian
set delete oN
sethandlecount(450)
set _3dlook on


/// leer correos de gmail

TRY
聽 聽 聽 oeleben := CreateObject( "ClassLibrary2.Class1" )
聽 聽 聽 
聽 聽 聽 ? "entro a leer correos de gmail "
CATCH
聽 聽 聽 ? "entro "
END

if oeleben:eleconecion("pop.gmail.com",995,.t.) 聽 聽//pop, puerto, ssl= .t. o .f.
聽 聽? "entro a la conexion "
else
聽 聽? "no entro a la conexion no paso la prueba"
聽 聽return nil
endif

if oeleben:eleusuario("xxxx@gmail.com","xxxxx") 聽 聽 //usuarioa 聽 聽contrase@a
聽 聽? "entro a la autentificacion"
聽 
else
聽 聽? "no entro a la autentificacion"
聽 聽return nil
endif
ncorreos:=oeleben:registros()
? "numero de correos ",ncorreos

for i:=1 to 聽 ncorreos
聽 聽 聽? oeleben:headerfrom(i)
聽 聽 聽? oeleben:headerdate(i)
聽 聽 聽? oeleben:headersubject(i)
聽 聽 聽? oeleben:headertextversion(i)
聽 聽 聽? oeleben:headerhtmlversion(i)
聽 聽 聽cadjuntos:=obtadjuntos(oeleben:headeradjuntos(i))
聽 聽 聽? " adjuntos ", oeleben:headeradjuntos(i)
聽 聽 聽? "numero de adjuntos", len(cadjuntos)
聽 聽 聽
聽 聽 聽for n:=1 to len(cadjuntos) 聽 // imprimir nombre de adjuntos 聽y se graba en el directorio dode corre el programa
聽 聽 聽 聽 聽? cadjuntos[n], n
聽 聽 聽next n
next i

? "desconexion",oeleben:desconectar()

? "termino we"

Return NIl



function obtadjuntos(xnombres)
local adev:={}
local dev:=""
local i:=0
for i:=1 to len(xnombres)
聽 聽if substr(xnombres,i,1)="|"
聽 聽 聽 aadd(adev,dev)
聽 聽 聽 dev:=""
聽 聽else
聽 聽 聽 dev:=dev+substr(xnombres,i,1)
聽 聽endif
next i
return adev


hay que registrar la dll ClassLibrary2.dll
con r.bat
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: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dll para leer pop3 gmail
Posted: Sat Jun 06, 2015 09:54 AM

Gracias! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dll para leer pop3 gmail
Posted: Fri Jul 17, 2015 08:12 AM

Lo he probado y no me funciona.

Alguien tiene c贸digo que funcione para leer los correos de gmail ?

gracias!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dll para leer pop3 gmail
Posted: Fri Jul 17, 2015 02:54 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 120
Joined: Wed Mar 11, 2009 07:32 PM
Re: Dll para leer pop3 gmail
Posted: Fri Jul 17, 2015 04:55 PM

hola buenos dias antonio

la dll funciona perfectamente

hay que darle permiso a la cuenta de gmail
habilitando pop en configuracion y reeinvio y correo pop/imap

tambien ay que checar si el antivirus esta bloqueando el servicio

saludos

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: 120
Joined: Wed Mar 11, 2009 07:32 PM
Re: Dll para leer pop3 gmail
Posted: Fri Jul 17, 2015 05:03 PM
hola

le anexe una prueba se llama visorxml.exe

ay le pueden mandar mensajes a la cuenta de eleben143@gmail.com

y los recibe

http://www.eleben.com.mx/gmail.zip

saludos

nota: hay que registrar la dll
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: 1078
Joined: Thu Sep 27, 2007 03:47 PM
Re: Dll para leer pop3 gmail
Posted: Fri Jul 17, 2015 11:12 PM

Saludos

RegAsm.exe Que hace este Exe,

Ejecuto visorxml.exe y sale este mensaje "no Entro puto"

Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
Posts: 120
Joined: Wed Mar 11, 2009 07:32 PM
Re: Dll para leer pop3 gmail
Posted: Sat Jul 18, 2015 01:56 PM

hola buenos dias

ese registra la dll
para poder usarla

saludos

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: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dll para leer pop3 gmail
Posted: Mon Jul 20, 2015 09:56 AM
Ojo que no conocemos el contenido de estas DLLs y alguien podr铆a estar obteniendo nuestras contrase帽as.

Los que hayais probado este c贸digo, lo id贸neo es que cambieis vuestras contrase帽as.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 120
Joined: Wed Mar 11, 2009 07:32 PM
Re: Dll para leer pop3 gmail
Posted: Mon Jul 20, 2015 03:18 PM
hola buenos dias
la dll la ralize yo en c#,
porque en c# ,, porque de una manera facil se pueden llamar todos los metodos y propiedades de cualquier dll
anexo el codigo de la libreria en c# , (tambien la podemos hacer lib de fivewin )

asi mismo veran que es muy facil es realizar cualquier llamado a dll
y cualquier persona que me lo pida le puedo dar todo el proyecto sin ningun problema y con toda la confianza del mundo bajando el visual estudio 2010 o 2013 express
ustedes mismo lo pueden compilar y genrerar su propia dll y llamarla asi desde fivewin sin ningun problema

saludos



Code (fw): Select all Collapse
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Xml;
using System.IO;
using System.Reflection;

// agregado de la securyty   
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Security.Permissions;
using System.Security.Cryptography.X509Certificates;


using System.ComponentModel;
using System.Data;
using System.Threading.Tasks;
using OpenPop.Mime;
using OpenPop.Mime.Header;
using OpenPop.Pop3;
using OpenPop.Pop3.Exceptions;
using OpenPop.Common.Logging;
using EmailMessage = OpenPop.Mime.Message;


//{DC5A21DC-5D65-4EBA-A75C-08EA7DF16DB8}

namespace ClassLibrary2

{
    [ComVisibleAttribute(true)]  //Deja la clase visible para COM
    [Guid("DC5A21DC-5D65-4EBA-A75C-08EA7DF16DB8")]
    [ProgId("ClassLibrary2.Class1")] //Identificador para poder Acceder a esta clase desde el exterior 


    public class Class1
    {
          Pop3Client client = new Pop3Client();
          private IContainer components;
      //    private SaveFileDialog saveFile;
        

        List<OpenPop.Mime.MessagePart> adjuntos;

        public string CERTIFICADO  {get; set;}
        public String USUARIO      {get; set;}
        public String LLAVE        {get; set;}
        public String SUBJECT      {get; set;}
        public String ISSUER       {get; set;}
        public int    VERSION      {get; set;}
        public int    llave        {get; set;}
        public DateTime VALIDDATE  {get; set;}
        public DateTime EXPIRYDATE {get; set;}
        public String THUMBPRINT   {get; set;}
        public String SERIAL       {get; set;}
        public String FRIENDLYNAME {get; set;}
        public String PUBLICKEY    {get; set;}
        public String PRIVATEKEY   {get; set;}
        public String RAWDATA      {get; set;}
        public String CERSTRING    {get; set;}
        public String CERXMLSTRING {get; set;}
        public String TIPOERROR    {get; set;}
        public String FILE         {get; set;}
        public String cdevuelve    {get; set;}
        public String RUTAD        {get; set;}

        internal  static byte[] ReadFile(string fileName)
        {
            FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            int size = (int)f.Length;
            byte[] data = new byte[size];
            
            size = f.Read(data, 0, size);
            f.Close();
            return data;
        }

        public string holita(string queondas)
        {
            Console.WriteLine("aaaaaaaaa"+queondas);
            Console.ReadLine();
            return "aaa";
        }


        public bool eleconecion (string direcion, int puerto, bool lssl)
        {
            bool dev = false;
            try
            {
                client.Connect(direcion, puerto, lssl); // si es ssl o no es ssl


                dev = true;
            }

            catch (Exception e)
            {
                dev = false;
            }
            
            return dev;

        }

        public bool eleusuario (string usuario, string contra)
        {
            bool dev = false;

        try
        
           {
               client.Authenticate(usuario, contra);
               dev = true ; 

               
            }
            catch (Exception)
            {
               dev = false;
           
             }

        return dev;
        }

        public int registros()
        {
            int dev = 0;

            try
            {
                dev = client.GetMessageCount();

            }
            catch (Exception)
            {
                dev = 0;

            }

            return dev;
        }

        public bool desconectar()
        {
            bool dev = false;

            try
            {
                client.Disconnect();
                dev = true;
            }
            catch (Exception)
            {
                dev = false;

            }
            return dev;
        }


        public string headerfrom (int men)
        {
           string dev ="";

           try 
            {           
            
               string adev = client.GetMessage(men).Headers.From.ToString();

               dev = adev;
             }
            catch (Exception)
            {
        
               dev = "";
            }

            return dev;
        }

        public string headerdate(int men)
        {
            string dev = "";

            try
            {

                string adev = client.GetMessage(men).Headers.Date.ToString();

                dev = adev;
            }
            catch (Exception)
            {

                dev = "";
            }

            return dev;
        }


        public string headersubject(int men)
        {
            string dev = "";

            try
            {

                string adev = client.GetMessage(men).Headers.Subject.ToString();

                dev = adev;
            }
            catch (Exception)
            {

                dev = "";
            }

            return dev;
        }

        public string headertextversion(int men)
        {
            string dev = "";

            try
            {

                string adev = client.GetMessage(men).FindFirstPlainTextVersion().GetBodyAsText();

                dev = adev;
            }
            catch (Exception)
            {

                dev = "";
            }

            return dev;
        }

        public string headerhtmlversion(int men)
        {
            string dev = "";

            try
            {

                string adev = client.GetMessage(men).FindFirstHtmlVersion().GetBodyAsText();


                dev = adev;
            }
            catch (Exception)
            {

                dev = "";
            }

            return dev;
        }


        public string headeradjuntos(int men)
        {
            string dev = "";

            try
            {
                string adev = client.GetMessage(men).FindFirstHtmlVersion().GetBodyAsText();
                adev = client.GetMessage(men).FindAllAttachments().ToString();

                EmailMessage message = client.GetMessage(men);  // es el valor de un mensaqje we
                List<MessagePart> adjuntos = message.FindAllAttachments();
                foreach ( MessagePart adjunto in adjuntos)
                {
                    dev = dev +adjunto.FileName+"|";
                    FileInfo file = new FileInfo(adjunto.FileName);
                    if (file.Exists)
                    {
                        // User was asked when he chose the file, if he wanted to overwrite it
                        // Therefore, when we get to here, it is okay to delete the file
                     //   dev = dev + "si existes el archivo y se borro" + "|";
                        file.Delete();
                    }

                    // Lets try to save to the file
                    try
                    {
                        adjunto.Save(file);
                       // dev = dev + "se grabo el archivo wey" + "|";
                       // MessageBox.Show(this, "Attachment saved successfully");
                    }
                    catch (Exception )
                    {
                     //   MessageBox.Show(this, "Attachment saving failed. Exception message: " + e.Message);
                        dev = dev + "marco error en grabdo de datos we" + "|";

                     //   return dev;
                    }
                }
                

                
               // crear lista de los adjuntos putos
               
                
            }
            catch (Exception)
            {
                dev = "";
            }
            return dev;
        }


           

        public string LEERCERTIFICADO (string xcertificado)
       
           {

            try
            {
               
                X509Certificate2 x509 = new X509Certificate2();
                //Create X509Certificate2 object from .cer file. 
                //byte[] rawData = ReadFile(args[0]);
                byte[] rawData = ReadFile(xcertificado);
                
                x509.Import(rawData);
                
                SUBJECT = x509.Subject;
                ISSUER = x509.Issuer;
                VERSION = x509.Version;
                VALIDDATE = x509.NotBefore;
                EXPIRYDATE = x509.NotAfter;
                THUMBPRINT = x509.Thumbprint;
                SERIAL = x509.SerialNumber;
                FRIENDLYNAME = x509.FriendlyName;

                PUBLICKEY = x509.PublicKey.ToString();
                PRIVATEKEY = x509.PrivateKey.ToString();
                RAWDATA = x509.RawData.ToString();
               
                CERSTRING = x509.ToString(true);
               

                CERXMLSTRING = x509.PublicKey.Key.ToXmlString(false);

                //Add the certificate to a X509Store.
                X509Store store = new X509Store();
                store.Open(OpenFlags.MaxAllowed);
                store.Add(x509);
                store.Close();
            }

            catch (DirectoryNotFoundException)
            {
               TIPOERROR ="Error The directory specified could not be found";
            }
            catch (IOException)
            {
                TIPOERROR = "Error A file in the directory could not be accessed.";
            }
            catch (NullReferenceException)
            {
                TIPOERROR = "File must be a .cer file. Program does not have access to that type of file.";
            }

            return "aaaa";
        }



        public string xfile( string cruta )
            

        {
            byte[] pele = File.ReadAllBytes(@cruta);
            string result = System.Text.Encoding.ASCII.GetString(pele);
            // convertir a base 64
            string base64String;
            try
            {
                base64String =
                  System.Convert.ToBase64String(pele,
                                         0,
                                         pele.Length);
            }
            catch (System.ArgumentNullException)
            {
               // System.Console.WriteLine("Binary data array is null.");
                return "error Binary data array is Null";
            }

            return base64String;
        }
        
        
        }
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: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dll para leer pop3 gmail
Posted: Mon Jul 20, 2015 03:46 PM

Gracias por publicar el c贸digo, asi se despeja cualquier duda al respecto.

Te pido disculpas si te ha podido molestar mi mensaje. S贸lo lo he hecho por seguridad de todos
pues alguna de las DLLs usada talvez no es tuya y no se sabe con certeza que puedan hacer
con los datos proporcionados.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 120
Joined: Wed Mar 11, 2009 07:32 PM
Re: Dll para leer pop3 gmail
Posted: Mon Jul 20, 2015 03:56 PM

hola antonio

buenos dia

la dll
la saque de http://hpop.sourceforge.net/

ayi tambien viene su codigo fuente y pruebas

yo lo unico que hice fueron los llamados

y asi como tu dice , tenemos que probarla , yo de antemano ya tengo tiempo usandola y a todo dar

saludos

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

Continue the discussion