using System.Net.Mail;
using System.Net.Mime;
using System.Drawing;
namespace RnDConsoleCSharp
{
class Program
{
static void Main(string[] args)
{
SendMail();
Console.Read();
}
//program to send mail
public static void SendMail()
{
/******* IMAGE FOR EMAIL *********/
Image EmailLogo = RnDConsoleCSharp.Resources.mylogo;
byte[] commentImg;
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
EmailLogo.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg );
commentImg = stream.ToArray();
}
/**********************************/
try
{
MailAddress from = new MailAddress("rupeshn@mindfiresolutions.com");
MailAddress to = new MailAddress("logintoabhi@hotmail.com");
MailMessage message = new MailMessage(from, to);
message.IsBodyHtml =true;
message.Subject ="TEST with image";
string bodyText = "
| Staff Name: | \" + staffName + \" |
| Staff Query: | \" + queryText + \" |
message.Body = bodyText;
SmtpClient client = new SmtpClient("NETSERVER");
client.Send(message);
}
catch (Exception ex)
{
Console.WriteLine("E-Mail Failed\n\n" + ex, "Email");
}
}
}
}
No comments:
Post a Comment