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() );
}
}
you have given SMTPclient credentials in wrong place...see below...
System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient();
SMTP.Credentials = new System.Net.NetworkCredential("info@cvghb.com", "c5v@a");
Instead of use below lines.
System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient("info@cvghb.com", "c5v@a");
SMTP.Credentials = CredentialCache.DefaultNetworkCredentials;
kirank28
Participant
792 Points
551 Posts
error on send mail
Apr 06, 2012 07:44 PM|LINK
hi i m using bigrock cp for my website, i m writing a code to send email from application below is the code but it get shows the error on send
System.Net.Mail.MailMessage eMail = new System.Net.Mail.MailMessage();
eMail.IsBodyHtml = true;
eMail.Body = "test";
eMail.From = new System.Net.Mail.MailAddress("info@cvb.com");
eMail.To.Add("cvb@gmail.com");
eMail.CC.Add("info@cvb.com");
eMail.Subject = "hi test from cvb";
System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient();
SMTP.Credentials = new System.Net.NetworkCredential("info@cvghb.com", "c5v@a");
SMTP.Host = "127.0.0.1";
SMTP.Send(eMail);
is this ok, i need to change host name or wht plz suggest.
MahadPK
Participant
778 Points
225 Posts
Re: error on send mail
Apr 06, 2012 07:49 PM|LINK
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() ); } }kirank28
Participant
792 Points
551 Posts
Re: error on send mail
Jul 27, 2012 07:08 PM|LINK
thank you ,
can you suggest me whats wrong on my code.
Primillo
Star
8841 Points
1701 Posts
Re: error on send mail
Jul 27, 2012 07:56 PM|LINK
Check out this tutorials
asp.net 2.0
http://www.systemnetmail.com/
asp.net 4.0
http://www.systemwebmail.com/
Primillo
http://www.facebook.com/programandopuntonet
Ramesh Chand...
Star
12922 Points
2672 Posts
Re: error on send mail
Jul 28, 2012 01:28 AM|LINK
what error you are getting ?
subhash.shel...
Contributor
2137 Points
487 Posts
Re: error on send mail
Jul 28, 2012 01:56 AM|LINK
Hi,
you have given SMTPclient credentials in wrong place...see below...
System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient(); SMTP.Credentials = new System.Net.NetworkCredential("info@cvghb.com", "c5v@a"); Instead of use below lines. System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient("info@cvghb.com", "c5v@a"); SMTP.Credentials = CredentialCache.DefaultNetworkCredentials;Thanks
Subhash
Subhash
Please, Mark as Answer if this reply helped you.