This repository has been archived on 2019-05-20. You can view files and clone it, but cannot push or open issues or pull requests.
vn-fingerprint/LectorVerdnatura/mail.cs

41 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Web;
using System.Net;
namespace LectorVerdnatura
{
class mail
{
const string FromEmail = "vfalco@verdnatura.es";
const string From="vfalco";
const string FromPasswd="vyp";
const string To="vicente.falco@gmail.com";
const string smtpServer="smtp.verdnatura.es";
const int port=25;
static System.Net.Mail.MailMessage Email;
public static void enviaremail(String SubjectEmail, String BodyEmail)
{
MailMessage email = new MailMessage();
email.To.Add(new MailAddress(To));
email.From = new MailAddress(FromEmail);
email.Subject = SubjectEmail;
email.Body = BodyEmail;
SmtpClient clienteSmtp = new SmtpClient(smtpServer);
//smtpMail.UseDefaultCredentials = true;
clienteSmtp.UseDefaultCredentials = true;
clienteSmtp.Credentials = new NetworkCredential(From, FromPasswd);
try { clienteSmtp.Send(email); }
catch (Exception ex)
{
logevent.logeventwrite("Error al enviar email a "+To + "con la cuenta "+From + " al servidor "+smtpServer);
logevent.logeventwrite("Error: " + ex.ToString());
}
}
}
}