send mail problem

I try to send email from my application. Everything seems ok, mailmessage, credentials etc.

When I debug the code it doesnt fall in to catch exception and doesnt send email. Also there is no mail queue at the server.There is no error message.

msgObj.Subject = this.Subject;        
    msgObj.From = new MailAddress(this.From , this.Display_Name);//
    msgObj.Body = this.Message;
    msgObj.IsBodyHtml = true;

    SmtpClient client = new SmtpClient(this.SMTP_Server,25);
                client.Credentials = new System.Net.NetworkCredential(SMTP_User + "", SMTP_Password);

                    return true;
                catch (Exception ex)
                    return false;

What could be the problem?



The default settings of an SmtpClient can be configured using the System.Net configuration namespace, e.g:

      <smtp deliveryMethod="network" from="">
        <network host="localhost" port="25" defaultCredentials="true" />

See the <smtp> Element (Network Settings) topic for more information.

Check for port. Is port 25 you are using support. Also check for SSL. If still not works. Try below code.

 /// <summary>
/// Transmit an email message
/// </summary>
/// <param name="from">Senders Name </param>
/// <param name="fromPerson">Sender Email Address</param>
/// <param name="body">The Email Message Body</param>
/// <returns>Status Message as String</returns>
public static void SendMail(string fromEmail, string fromName, string body)


        using (MailMessage mail = new MailMessage())
            mail.From = new MailAddress(fromEmail, fromName);
            mail.Subject = "Report ";
            mail.SubjectEncoding = System.Text.Encoding.UTF8;
            mail.Body = body;
            mail.BodyEncoding = System.Text.Encoding.UTF8;
            mail.Priority = MailPriority.High;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = global::ProjectName.Properties.Settings.Default.Host;
            smtp.Port = global::ProjectName.Properties.Settings.Default.Port;

            if (smtp.Port == 587)
                smtp.EnableSsl = true;
            string userName = global::ProjectName.Properties.Settings.Default.UserName;
            string password = global::ProjectName.Properties.Settings.Default.Password;
            smtp.Credentials = new NetworkCredential(userName, password);


    catch (SmtpException smEx)
        LogError(smEx.Message, smEx.StackTrace);

Here I am using Settings file of the project and retrieving values from there.

Need Your Help

Why I cannot modify some registers of BBB using /dev/mem?

linux mmap beagleboneblack

I know from TRM that to modify values in control registers I need privileged mode and this can be done with kernel module in Linux.

Golang changing values of a struct inside a method of another struct

pointers go struct slice

I have an issue with structs and maybe an issue with pointers, if my guess is correct.