Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to send mail here but i got this error "System.Net.Mail.SmtpException: The operation has timed out." . Please help me


C#
private void SendMail()
    {
        MailMessage mail = new MailMessage();

        mail.From = new MailAddress(txtEmail.Text.Trim());
        mail.To.Add("mailid");

        mail.Subject = txtSubject.Text.Trim();
        mail.IsBodyHtml = true;
        mail.Body = GetBody();

        
        SmtpClient smtpClient = new SmtpClient();
        smtpClient.Host = "relay-hosting.secureserver.net";//smtpout.secureserver.net
        smtpClient.Port = 25;
        
        smtpClient.UseDefaultCredentials = false;
        smtpClient.Credentials =
                  new NetworkCredential("mailid", "password");

        
        smtpClient.Timeout = 20000;
        smtpClient.Send(mail);
    }
Posted
Updated 20-Dec-22 9:01am
v2
Comments
Sergey Alexandrovich Kryukov 12-Aug-14 16:00pm    
Did you try to send a message using the same SMTP server and same parameters/authentication using some existing mail client? What if the server is not properly configured, or your authentication is incorrect, the account not properly set up?
—SA
Sergey Alexandrovich Kryukov 12-Aug-14 18:38pm    
And it's not clear how it could be related to Office 365.
—SA
Shahnawazcode 13-Aug-14 8:35am    
this website is hosted in godaddy and also email run from godaddy. The mail address is sshalemo@ad-betparkingservice.com.
gggustafson 13-Aug-14 23:28pm    
I would try: Host: smtpout.secureserver.net Port: 587 EnableSsl: true
Member 11892795 2-Oct-21 6:29am    
Thanks it works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900