I want to send email from my .net application. Please tell me the steps for sending email.
Asked
Active
Viewed 144 times
-1
-
1@user601367 It would have helped to tag your question with the language you want to use; or with ".NET" at the very least. Retagging... – razlebe Apr 12 '11 at 11:35
-
1[This](http://www.codeproject.com/KB/IP/SendMailUsingGmailAccount.aspx) tutorial can be helpful to you. For more search on Google for it. It is **free** to search on it. – Harry Joy Apr 12 '11 at 11:29
-
1Why don't you just google the answer? Supposing you want the answer in C# you can follow for example msdn [solution](http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8/) – tchrikch Apr 12 '11 at 11:31
-
Please check the link http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx – Mahesh KP Apr 12 '11 at 11:33
1 Answers
2
Start by exploring System.Net.Mail.SmtpClient type in .net. This type offers overload method Send.
Look here
public static void CreateTestMessage1(string server, int port)
{
string to = "jane@contoso.com";
string from = "ben@contoso.com";
string subject = "Using the new SMTP client.";
string body = @"Using this new feature, you can send an e-mail message from an application very easily.";
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient(server, port);
// Credentials are necessary if the server requires the client
// to authenticate before it will send e-mail on the client's behalf.
client.Credentials = CredentialCache.DefaultNetworkCredentials;
try
{
client.Send(message);
}
catch (Exception ex)
{
Console.WriteLine("Exception caught in CreateTestMessage1(): {0}",
ex.ToString());
}
}

honzajscz
- 2,850
- 1
- 27
- 29