Página 1 de 7

Send_EmailDLL

Publicado: 05 Jun 2011 23:24
por rafaxplayer
Saludos gente , aquí os dejo una dll que he realizado para mandar emails desde ams , la verdad es que se puede hacer mejor y pienso añadirle mas parámetros y opciones , también creo que debería realizar alguna devolución cuando manda los correos , seguiré aprendiendo el código para poder mejorarla.

La dll permite enviar desde una cuenta gmail o hotmail .
solo dispone de una función "SendEmail" con los siguientes parámetros:

string From : string con la cuenta gmail desde donde enviamos el email.
string To : Destinatarios es un string delimitado con las cuentas que queramos enviar el correo ejemplo: "[email protected],[email protected],[email protected]"
string NameFrom : Es un nombre o referencia que aparcecera delante del remitente ejemplo: rafael <<[email protected]>>
string Pass : El password de nuestra cuenta gmail, necesitamos autentificacion para usar el servidor smtp.gmail.com
string Subject : Titulo o asunto del correo
string body : correo en si
string Attachments : string con las rutas d elos archivos a adjuntar delimitados por ',' ejemplo : " path1, path2, path3" de los archivos adjuntados.
string Host : Dos opciones de servidor de salida de correo para GMail : "smtp.gmail.com" y para Hotmail: "smtp.live.com"
Retorno :
booleano Si el correo se ha enviado correctamente nos retorna true, en caso de error false .

Source code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;
using System.Net.Mime;
using RGiesecke.DllExport;

namespace E_Mail
{
internal static class UnmanagedExports
{

[DllExport("SendEmail", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]

static bool SendEmail(string FromGmail, string Name,string pass, string To, string subject, string message , string AttachmentsFiles, string host)
{
int port;
switch(host){
case "smtp.gmail.com":
host = "smtp.gmail.com";
port=587;
break;
case "smtp.live.com":
host = "smtp.live.com";
port=25;
break;
default :
host = "smtp.gmail.com";
port = 587;
break;

}


MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Credentials = new System.Net.NetworkCredential(FromGmail, pass);
SmtpServer.Port =port;
SmtpServer.Host = host;
SmtpServer.EnableSsl = true;
mail = new MailMessage();
String[] addr =To.Split(',');
try
{
mail.From = new MailAddress(FromGmail, Name, System.Text.Encoding.UTF8);
Byte i;
for (i = 0; i < addr.Length; i++)
mail.To.Add(addr);
mail.Subject = subject;
mail.Body = message;

if (AttachmentsFiles != "")

{
String[] att = AttachmentsFiles.Split(',');
foreach (string s in att)

if (s.Trim() != "")
mail.Attachments.Add(new Attachment(s));

}

mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
mail.ReplyTo = new MailAddress(To);
SmtpServer.Send(mail);
return true;
}
catch (Exception ex)
{
return false;
}
}

}
}



Captura :

Imagen

Apz incluye la dll en Autoplay/Docs :


-=-=-= Update 1.0.0.3=-=-=-

Cambios :

- Añadido posibilidad de envió desde cuentas hotmail.
- Cambio de retorno de la dll a boleano.
- Nuevo parámetro host.

-=-=-= Update 1.0.0.1=-=-=-

Cambios :

- añadido retorno de errores y algún arreglillo de script

Descarga :

HIDE: ON
Hidebb Message Hidden Description

Re: Send_EmailDLL

Publicado: 05 Jun 2011 23:52
por Agotaras123
genial amigo yo tenia una apz de ir creo que mandaba correos también pero con cuentas popup, bueno se te agradece tan buen aporte sin duda sera de mucha ayudara para muchos.

Re: Send_EmailDLL

Publicado: 06 Jun 2011 01:38
por xxsolracxx
gracias

Re: Send_EmailDLL

Publicado: 06 Jun 2011 23:52
por carsonzillo
interesante plugin pajaro!

Re: Send_EmailDLL

Publicado: 07 Jun 2011 01:24
por patch
gracias

Re: Send_EmailDLL

Publicado: 08 Jun 2011 17:50
por rafaxplayer
Update 1.0.01

Re: Send_EmailDLL

Publicado: 09 Jun 2011 21:44
por abood1987
good

Re: Send_EmailDLL

Publicado: 15 Jun 2011 00:43
por ahmed elsayed
thank you for this dll

Re: Send_EmailDLL

Publicado: 04 Jul 2011 14:08
por nghethihieu
this dll can hide the send and continue work with send email one time ?

Re: Send_EmailDLL

Publicado: 04 Jul 2011 23:07
por DaLion
Usando Sabiamente es Dll ;) tankes

Re: Send_EmailDLL

Publicado: 04 Jul 2011 23:13
por er_mejor
o.O muchas gracias! me servirá.

Re: Send_EmailDLL

Publicado: 10 Jul 2011 05:04
por Cyberkiller
Vemos... puede servir para un proyecto que deseo realizar

Re: Send_EmailDLL

Publicado: 11 Jul 2011 17:37
por Phaelitico
gracias

Re: Send_EmailDLL

Publicado: 11 Jul 2011 19:36
por dangngocnguyenit
thanks

Re: Send_EmailDLL

Publicado: 22 Ago 2011 20:31
por wander031180
Muy buen, pero buen aporte!

Re: Send_EmailDLL

Publicado: 05 Sep 2011 19:29
por spiderman
it's a good dl ..thanx :lol:

Re: Send_EmailDLL

Publicado: 27 Sep 2011 12:06
por bumbo
bravisimo

Re: Send_EmailDLL

Publicado: 24 Oct 2011 01:25
por milano88
thanks mate

Re: Send_EmailDLL

Publicado: 24 Oct 2011 10:51
por mecivic
Thank you

Re: Send_EmailDLL

Publicado: 21 Nov 2011 16:18
por Haitham.2012
wooow .. it's nice