Click here to Skip to main content
15,900,254 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Following is my code:-
C#
string to, sub, mess;
            to = "info@sdmmedicalcollege.org";
            sub ="Weekly Clinical Quiz";
            mess ="Quiz Title: " + dr["Quiz_Title"].ToString() + "<br>Name: " + txtName.Text + "<br> Email: " + txtEmail.Text + "<br>Clinical Diagnosis: " + txtContent.Text;
            mess = mess + "<br> Occupation : " + txtOccupation.Text + "<br>Institution: " + txtInst.Text;
            //  tel = "99";

            //MailMessage mg = new MailMessage();
            //MailMessage mg = new MailMessage(txtEmail.Text, "info@sdmmedicalcollege.org");
            MailMessage mg = new MailMessage(txtEmail.Text, dr["Quiz_Email"].ToString());  
            mg.Subject = sub;
            mg.Body = mess;
            mg.IsBodyHtml = true;
            SmtpClient st = new SmtpClient();
            st.EnableSsl = true;
            st.Host = "smtp.secureserver.net";
            st.Port = 25;
            st.Credentials = new System.Net.NetworkCredential("info@sdmmedicalcollege.org", "hospital");
            st.UseDefaultCredentials = true;
            st.DeliveryMethod = SmtpDeliveryMethod.Network;
            st.Send(mg);

When am trying to run this on server,am getting following exception,
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. ua5sm10078511igb.10

I tried with the different port numbers like 457,565 but it didnt work out for me.

Can anyone please help me??
Posted
Updated 30-Aug-12 0:09am
v3

When you use st.UseDefaultCredentials = true;
st.Credentials will be ignored and currently logged on user credentials will be used.

If you specify Credentials explicitly, leave UseDefaultCredential = false

http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials[^]
 
Share this answer
 
v2
 
Share this answer
 

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