using System;
using System.Web.Mail;
namespace WebMail
{
class Class1
{
static void Main(string[] args)
{
try
{
MailMessage oMsg = new MailMessage();
oMsg.From = "sender@somewhere.com";
oMsg.To = "recipient@somewhere.com";
oMsg.Subject = "Send Using Web Mail";
oMsg.BodyFormat = MailFormat.Html;
oMsg.Body = "<HTML><BODY><B>Hello World!</B></BODY></HTML>";
String sFile = @"C:\temp\Hello.txt";
MailAttachment oAttch = new MailAttachment(sFile, MailEncoding.Base64);
oMsg.Attachments.Add(oAttch);
SmtpMail.SmtpServer = "MySMTPServer";
SmtpMail.Send(oMsg);
oMsg = null;
oAttch = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
}
}
}
Add a reference to the System.Web.dll namespace
No comments:
Post a Comment
Thank you for Commenting Will reply soon ......