Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi all,

I am sending mail after data's saved in DB. mail sending is working fine in my system.
but when i host it in client system mail is not sent.

           string ToMailIds = string.Empty;
        string CCMailIds = string.Empty;

        System.Net.Mail.MailMessage EMail = new System.Net.Mail.MailMessage();
EMail.To.Add(new System.Net.Mail.MailAddress(toaddress.Text));
          
            EMail.Subject = txtsubject.Text ;
            EMail.Body = "<font face="verdana" size="2">" + txtmsg.Text + "</font>";
            EMail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();
            NetworkCredential net = new NetworkCredential();
            EMail.From = new MailAddress(txtusername.Text);
            net.UserName = txtusername.Text;
            net.Password = txtpassword.Text;
            smtp.Credentials = net;
            if (net.UserName.Contains("gmail") == true)
            {
                smtp.EnableSsl = true;
            }
            smtp.Host = txtserver.Text;
            smtp.Send(EMail);
Posted

 
Share this answer
 
this method works fine
C#
public static Boolean SendingMail(string From, string To, string Subject, string Body)
    {
        
            try
            {
                MailMessage m = new MailMessage("Test<sender@gmail.com>", To);
                m.Subject = Subject;
                m.Body = Body;
                m.IsBodyHtml = true;
                m.From = new MailAddress(From);
 
                m.To.Add(new MailAddress(To));
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "mail.google.com";
              
                NetworkCredential authinfo = new NetworkCredential("test@gmail.com", "te1234");
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = authinfo;
                smtp.Send(m);
                return true;
 
               
 

            }
            catch (Exception ex)
            {
                return false;
            }
        }
 
Share this answer
 
Comments
Janardan Pandey 4-Nov-11 6:40am    
i dont want to give email id and password because i am doing this for sending feed back of a website.Please help me for my need
 
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