Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everybody,
i have serious problem in my web site.
i had use some sort of code to send email in my website.the problem is that code works properly in one page and don't work on the other page.
i'm completely confused.
the code behind and web.config :


MailMessage mail = new MailMessage();
 mail.From = new MailAddress("contacts@website.com");
 mail.To.Add(DropDownList1.SelectedValue);
mail.Subject = txtSubject.Text;
 mail.Body = "<div>something...</div>";
 mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("mailserver.com");
smtp.Credentials = new NetworkCredential("contacts@website.com","password");
smtp.Send(mail);




W E B . C O N F I G

<pre lang="xml"><system.net>
    <mailSettings>
      <smtp>
        <network defaultCredentials="false"/>
      </smtp>
    </mailSettings>
  </system.net>





every solution will be appreciated
thanks
Posted
Comments
Sandeep Mewara 5-Oct-10 16:51pm    
Elaborate 'not working' ?
Ankur\m/ 6-Oct-10 5:34am    
Please do not add answer if you need to clarify something with the answerer. He doesn't get notified. Instead use 'Add Comment' below his answer like I did.

1 solution

Hi What you mean by code works on one page and not in other page may be it is copy paste problem on code behind file, did you check the control ids, namespace included properly, place break point and see whether proper values are coming
 
Share this answer
 
Comments
Ankur\m/ 6-Oct-10 5:32am    
[moved from answer]
M0$!98 wrote:
thanks for ur answer.
ya i know what u mean.i check everything and they are correct.
plz let me know if there is something about web.config or mailserver
i think the code is right am i wrong!?!?

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