You are on page 1of 1

using System;

using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;

namespace TestEMail
{
class Program
{
static void Main(string[] args)
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("@gmail.com");
mail.To.Add("");
mail.Subject = "Test Mail - 1";
mail.Body = "mail with attachment";

// System.Net.Mail.Attachment attachment;
// attachment = new System.Net.Mail.Attachment("c:/textfile.txt");
// mail.Attachments.Add(attachment);

SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("@gmail.com",
"");
SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);
}
}
}

You might also like