dhanjish Posted February 22, 2007 Share Posted February 22, 2007 hi,i am new to .net 2005. i used to work in .net 2003.So shall i know how to send a simple mail in 2005.i have tried many code but the mail is not going.Pleas elet me know..........Dhanjish Link to comment Share on other sites More sharing options...
aspnetguy Posted February 22, 2007 Share Posted February 22, 2007 please post your code. Are you getting error messages? Link to comment Share on other sites More sharing options...
pulpfiction Posted February 22, 2007 Share Posted February 22, 2007 Just check the namespace imported, "System.Web.Mail" namespace in ASP.NET 1.x is now "System.Net.Mail" namespace in ASP.NET 2.0...... Link to comment Share on other sites More sharing options...
milot Posted February 28, 2007 Share Posted February 28, 2007 Here is an example that I wrote earlier in C# to send e-mails from Gmail accounts, I think that will be useful for someone : // Using directivesusing System;using System.Net;// System.Net.Mail for SmtpClient and MailMessageusing System.Net.Mail;namespace gmailSender{ public class GmailSenderClass { public static void Main(string[] args) { try { // parameters for MailMessage are, FROM:, TO:, Subject: and Body: MailMessage message_ = new MailMessage("Example@gmail.com", "Example@hotmail.com", "Hi this is subject", "Hi this is body"); // This is to send text e-mails message_.IsBodyHtml = false; // parameters for NetworkCredential is username and password NetworkCredential mailAuthentication= new NetworkCredential("Example@gmail.com", "YourPassword"); // SmtpClient parameters are: host and port (you can see I have used the gmail ones) SmtpClient smtp_ = new SmtpClient("smtp.gmail.com", 587); // We don't want to use default credentials because we wrote ours above smtp_.UseDefaultCredentials = false; // Gmail requires SSL to be enabled so we set it to true smtp_.EnableSsl = true; // We pass the credentials that we have created to SmtpClient object smtp_.Credentials = mailAuthentication; // We happily send our message :D smtp_.Send(message_); } catch(Exception e) { Console.WriteLine("Message: {0}", e.Message + Environment.NewLine); } } }} Link to comment Share on other sites More sharing options...
dhanjish Posted March 3, 2007 Author Share Posted March 3, 2007 Hi all,Thanks for ur reply.I followed the following code and it wrkd Dim str As String lab.Visible = False MailMessage = New System.Net.Mail.MailMessage Dim username As String = "name" Dim pswd As String = "pswd" Dim credentials As New NetworkCredential("hostaddress", "password") client = New SmtpClient MailMessage.To.Add("daa@rediffmail.com") MailMessage.From = New MailAddress("gg@gmail.com") MailMessage.Subject = "Test" MailMessage.Body = "Hai hw r u ? " client.Host = "host address" Try client.Credentials = credentials client.Send(MailMessage) Catch ex As Exception If (ex.Message = "The remote name could not be resolved:'mail@divisionalforesttcr.org' ") Then str = " Failed!! your mail has not been sent because of some technical reasons " ' Response.Write(str) Else str = ex.ToString() ' Response.Write(str) End If End TryThanks for your support Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now