Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Failure Sending mail error is occurred in following code whats wrong in that code...
C#
string ActivationUrl;

            try
            {

                MailMessage message = new MailMessage();

                message.From = new MailAddress("XXXX@gmail.com");

                message.To.Add(txtemail.Text);

                message.Subject = "Verification Email";

                ActivationUrl = Server.HtmlEncode("http://localhost:9525/Important_Testing/Verification.aspx?USER_ID=" + GetUserID(txtemail.Text));

                message.IsBodyHtml = true;

                message.Body = "<a href="" + ActivationUrl + "">Click Here to verify your acount</a>";

                SmtpClient smtp = new SmtpClient();

                smtp.Credentials = new System.Net.NetworkCredential("XXXX@gmail.com", "XXXX");

                smtp.Host = "smtp.gmail.com";

                smtp.Port = 587;

                smtp.EnableSsl = true;

                smtp.Send(message);

            }

            catch (Exception)
            {
                throw;
            }
Posted
Updated 7-Dec-14 17:18pm
v2
Comments
[no name] 7-Dec-14 23:19pm    
What is the error ?
Member 11270220 7-Dec-14 23:20pm    
Failure sending mail
syed shanu 7-Dec-14 23:32pm    
Check my solution i have tried the first link it works fine for me.check for the missed line ,.update your code and test it.

1 solution

 
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