This is a discussion on How to Send mail using dot net ...? within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi All... How to send HTML mail in ASP.NET? thnks.......
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi Deeban... You can send mails using smtpclass... Here is the sample code... Code: MailMessage mail = new MailMessage(); mail.To = "To Address"; mail.From = "From Address"; mail.Subject = "Test."; mail.BodyFormat = MailFormat.Html; mail.Body = "Test Message"; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| Hi Deeban, Use System.Web.Mail The System.Web.Mail namespace contains classes that enable you to construct and send messages using the CDOSYS (Collaboration Data Objects for Windows 2000) message component. The mail message is delivered either through the SMTP mail service built into Microsoft Windows 2000 or through an arbitrary SMTP server. The classes in this namespace can be used from ASP.NET or from any managed application.
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| hi deeban, Namespace used in the .NET 2.0 is the System.Net.Mail that will allow you to send an email. The following is a basic example of sending a message: //Create a mail message MailMessage message = new MailMessage("From Address", "To Address", "Subject", "Body"); // Create a mail object specifying the address of your SMTP mail server SmtpClient mail = new SmtpClient("Mail Server Address"); mail.Send(message); If you take a look at the objects under this namespace (using the Object Explorer tool found under the View menu) you will see that the MailMessage object has properties to specify what format the email should be sent in (Text, HTML) and what priority should be given to the message among other things. Also, the SmtpClient object has properties that allow you to specify how the message should be sent. thanks.
__________________ Venkat knowledge is Power |
| |||
| Hi Deeban... Code: Install the SMTP virtual server that is part of IIS. · You will need your Windows installation CD. · Use Add or Remove Programs in the Windows Control Panel to launch Add/Remove Windows Components. · Select Internet Information Services (IIS) and then click Details. · Check SMTP Service and then click OK. · The installation process will prompt you for your Windows CD and will install the SMTP virtual server. After installing the SMTP server (also reboot), configure it by following these steps: 1. In the Control Panel, choose Administrative Tools, and then choose Internet Information Services. 2. Open the node for your computer, right-click the Default SMTP Virtual Server node and choose Properties. 3. In the Access tab, click Connection. 4. Select Only the list below, click Add and add the IP 127.0.0.1. This restricts connections to just the local computer, i.e., localhost. Close the Connection dialog box. 5. Click Relay and repeat Step 5 to allow only localhost to relay through this server. In your firewall or router (or both), close incoming port 25. This is an important security measure that will prevent spammers from finding your SMTP server and using it to relay spam.
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| Hi Deeban.... Code: This is a network related error. Your application cannot connect to the mail server specified. 1. Make sure that the following are true about SmtpMail.SmtpServer: 2. Is a valid SMTP Server 3. Make sure that the server System.Web.Mail is running or can connect to the mail server. Some times firewalls or proxy servers can get in the way. 4. Try specifying the value by IP address. Poor DNS resolution can sometimes hinder name lookups. 5. Make sure that the mail server is running at port 25. 6. If you did not specify a SmtpMail.SmtpServer property, or if SmtpMail.SmtpServer points to "localhost" (or the equivalent), be sure the SMTP Service is running on port 25. 7. For testing purposes change the MailMessage.From and MailMessage.To properties to an address that exists on SmtpMail.SmtpServer. Some times this exception is thrown, when it really is a relay issue.
__________________ Sathish Kumar.R ![]() Knowledge is meant to SHARE |
| |||
| using System.Web.Mail; MailMessage myMessage = new MailMessage(); myMessage.To = this.EmailAddress; myMessage.From = Environment.UserName + "@knowdotnet.com"; myMessage.Priority = this.MessagePriority; myMessage.Subject = String.Format("Message from {0} at {1}", this.From, this.Company); StringBuilder sb = new StringBuilder(); sb.Append(To + ", you received a Message from " + From + " with " + this.Company + "\r\n\r\n"); sb.Append("at " + MessageDate + " " + MessageTime + "\r\n\r\n"); sb.Append("Regarding : " + this.Regarding + "\r\n\r\n"); sb.Append("They : " + this.PhoneActions + "\r\n\r\n"); sb.Append("They can be reached at : " + this.Phone + "\r\n\r\n"); sb.Append("Their Message: " + this.Message + "\r\n\r\n"); sb.Append("Initialed: " + Environment.UserName); myMessage.Body = sb.ToString(); try { SmtpMail.Send(myMessage); } catch(System.Exception ex) { Debug.Assert(false, ex.ToString()); } |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to send mail with multiple attachments? | poornima | ASP and ASP.NET Programming | 5 | 02-01-2008 03:07 AM |
| How can we send mail using JavaScript? | sundarraja | PHP Programming | 2 | 01-22-2008 03:57 AM |
| send the sms using SMS/MMS Gateway in php | varghese | PHP Programming | 1 | 09-18-2007 08:32 AM |
| How can we send mail using JavaScript? | Sabari | HTML, CSS and Javascript Coding Techniques | 3 | 09-12-2007 12:33 AM |
| How to Send Mail Using Stored Procedure in MS SQL SERVER 200x?? | Gopisoft | Database Support | 1 | 07-17-2007 09:43 AM |