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: Select all
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. Obregon, Sonora, Mexico
chino72vale@hotmail.com
Fivewin 16.05, Harbour 3.2, xharbour 1.2.1, Fivelinux, visual estudio 2013