Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 13th, 2007, 12:38 AM
Authorized User
 
Join Date: Dec 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default sending mail in asp.net2.0

hi,

i am new to asp.net,in our web application if user forgets his password automaticaaly a password is generated and it should be mailed to him,plz can anybody tell me how send mail ....password generation is done but unable to send mail.......

thanks in advance
senthil

 
Old January 13th, 2007, 02:59 AM
Authorized User
 
Join Date: Dec 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sunnys Send a message via Yahoo to Sunnys
Default

hi,
well u can do this in two ways
first include
using System.Net;
using System.Net.Mail;
and then


System.Net.Mail.MailMessage objMailMessage = new System.Net.Mail.MailMessage();
            System.Net.Mail.SmtpClient objSmtpClient = new SmtpClient();
            MailAddress fromAddress = new MailAddress("mailAddress");
            objMailMessage.To.Add(System.Configuration.Configu rationManager.AppSettings["MailTo"]);
            objMailMessage.From = fromAddress;
            Literal ltMail=(Literal)MailParser1.FindControl("ltMail");

            objMailMessage.Subject = "Foo";

            objMailMessage.IsBodyHtml=true;
            objMailMessage.Body = "Body Part";
            objSmtpClient.Host = System.Configuration.ConfigurationManager.AppSetti ngs["ServerName"]; ;
            objSmtpClient.Send(objMailMessage);


and make entry in web.config
 <appSettings>
    <add key="MailTo" value="Email Address"/>
    <add key="MailCC" value=""/>
    <add key="ServerName" value="ServerIp(MailServername)"/>
  </appSettings>

 hope this will help



 
Old March 3rd, 2007, 07:14 AM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

i tried wit the code tat u provided but the problem wat i'm facing is it throws an exception at this particular line of code.Can u please help me out wid this,as i'm new to asp.net.

objMailMessage.To.Add(System.Configuration.Configu rationManager.AppSettings["MailTo"]);

Exception says:Value cannot be null.
               Parameter name: addresses

thank in advance
sam





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Mail Using CDOSYS in ASP artarasan Classic ASP Basics 1 May 12th, 2008 06:11 PM
Sending mail using asp.net 2.0 Roinka ASP.NET 2.0 Basics 0 May 15th, 2006 08:22 AM
Sending E-mail with ASP Varg_88 Classic ASP Basics 7 September 10th, 2004 09:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.