I have a problem with sending mails with ASP.NET when I am trying to use the System.Net.Mail
the code is below :
public void SendMailMessage(string from, string to, string bcc, string cc, string subject, string body) {
// Instantiate a new instance of MailMessage
MailMessage mMailMessage = new MailMessage();</FONT> // Set the sender address of the mail message
mMailMessage.From = new MailAddress(from);</FONT> // Set the recepient address of the mail message
mMailMessage.To.Add(new MailAddress(to));</FONT> // Check if the bcc value is null or an empty string
if ((bcc != null) && (bcc != string.Empty))</FONT> {
// Set the Bcc address of the mail message
mMailMessage.Bcc.Add(new MailAddress(bcc));</FONT> }
// Check if the cc value is null or an empty value
if ((cc != null) && (cc != string.Empty))</FONT> {
// Set the CC address of the mail message
mMailMessage.CC.Add(new MailAddress(cc));</FONT> } // Set the subject of the mail message
mMailMessage.Subject = subject;
// Set the body of the mail message
mMailMessage.Body = body;
// Set the format of the mail message body as HTML
mMailMessage.IsBodyHtml = true;</FONT> // Set the priority of the mail message to normal
mMailMessage.Priority = MailPriority.Normal;</FONT> // Instantiate a new instance of SmtpClient
SmtpClient mSmtpClient = new SmtpClient();</FONT> // Send the mail message
mSmtpClient.Send(mMailMessage);
}
SendMailMessage("mohamed_alaa_younis@hotmail.com", "mohamed_alaa_younis@yahoo.com", "", "", "i love you", "hello mohamed i want to be your friend !");
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Then the error appears when running the website :
No connection could be made because the target machine actively refused it 127.0.0.1:50025
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:25
What should I do ?
