hi friends...
i m new in c#.net..
i m going to develop some basic application like sending email from my application...
i got some code from internet...
but i m facing problem regarding setting of SMTP server..
can anybudy tell how to find out SMTP server name of our local machine...
plz anybudy help is any related url or any code plz share with me...........

namespace WebMail
{
class Class1
{
static void Main(string[] args)
{
try
{
MailMessage oMsg = new MailMessage();
// TODO: Replace with sender e-mail address.
oMsg.From = "i_prashant11@rediffmail.com";
// TODO: Replace with recipient e-mail address.
oMsg.To = "indapure.prashant@gmail.com";
oMsg.Subject = "Send Using Web Mail";


// SEND IN HTML FORMAT (comment this line to send plain text).
oMsg.BodyFormat = MailFormat.Html;


// HTML Body (remove HTML tags for plain text).
oMsg.Body = "<HTML><BODY><B>Hello World!</B></BODY></HTML>



// TODO: Replace with the name of your remote SMTP server.SmtpMail.SmtpServer = "MySMTPServer";//how to find SMTP server name of our local macine
SmtpMail.Send(oMsg);


oMsg = null;
//oAttch = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
}
}

Thanks in advance.

Prashant Indapure

Recommended Answers

All 3 Replies

If your local host address does not work, try the ip address of your server, this off course would work if the default smtp is install on your machine

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.