how to send a mail using c# in 2003 version
how to send a mail using c# in 2003 version
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhimanyu K VatsaPosted May 29, 2010, 10:42 AM
Thanks
Posted May 24, 2009, 3:51 PM
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Mail;
namespace consolemail
{
class Program
{
static void Main(string[] args)
{
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
System.Net.NetworkCredential AuthInfo = new
System.Net.NetworkCredential("[email protected]", "babilona");
message.To.Add("[email protected]");
message.Subject = "Test Mail using System.Net.Mail";
message.From = new MailAddress("[email protected]");
string str = "Hai to all";
message.Body = str;
bool isBodyHtml = true;
message.IsBodyHtml = isBodyHtml;
message.Attachments.Add(new Attachment("c:\\something.txt"));
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Priority = MailPriority.High;
smtp.Host = "smtp.gmail.com";
smtp.UseDefaultCredentials = false;
smtp.Credentials = AuthInfo;
smtp.Timeout = 20000;
smtp.Port = 587;
// use stmp.port = 587 if 465 does not work.
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
try
{
smtp.Send(message);
Console.WriteLine("E-mail has been sent succesfully");
Console.ReadLine();
}
catch (System.Net.Mail.SmtpException ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
}
}
Niradhip ChakrabortyPosted Apr 28, 2009, 3:45 AM
1.http://www.systemwebmail.com/faq/2.1.aspx
2.http://www.developer.com/net/asp/article.php/3096831
SreekanthPosted Apr 28, 2009, 1:14 AM
using System.Web.mail;
mms.From="[email protected]";//ur domain
mms.To="[email protected]";
mms.BodyFormat=MailFormat.Text;
mms.BodyFormat=MailFormat.Html;
mms.Body=my;//my os string ur body part
//This section provides the configuration information for the remote SMTP server.
mms.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2; //Send the message using the network (SMTP over the network).
mms.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] ="ur domain";eg:google.co.in
mms.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = 25;
mms.Fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"] = false; //Use SSL for the connection (True or False)
mms.Fields["http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"] = 60;
///// If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
mms.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1; //basic (clear-text) authentication
mms.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] ="[email protected]";
mms.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] ="iype";
SmtpMail.Send(mms);