Tuesday, August 25, 2009

Source Code For mailing in asp.net C#



Hello,
Friends I was looking at a source code which helps me to send mail from my asp.net web applications finally i got this coding which works fine.

Note: Tested On Godaddy Server, IXwebshoting


And dont forget to use namespace

using System.Net.Mail;

public void mail2()
{


try
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("support@forxxxx.com", "xxxx.com");
msg.To.Add("cool.xxxxx@gmail.com");
msg.Subject = "xxxx.com";
msg.Body = "Greetings from xxxx.com!
Thank you for registering in . We wish you success in your partner search. We hope you make the best use of the facilities available on this site – partner search, horoscope matching and other services; all of which comes absolutely free!!
We also advice you to update the profile as and when required.
This registration is valid for 3 months. Thereupon an email will be sent asking you to either activate or delete the profile. This is only to avoid unnecessary enquiries of profiles once the marriages are already settled.

Your member name";
msg.IsBodyHtml = true;

// MailMessage instance to a specified SMTP server
SmtpClient smtp = new SmtpClient("relay-hosting.secureserver.net", 25);
smtp.Credentials = new System.Net.NetworkCredential("support@XXXXX.com", "XXXXXX");
smtp.Port = 25;
// Sending the email
smtp.Send(msg);
Response.Write("Mail Sent");
// destroy the message after sent
msg.Dispose();
}
catch (Exception ex)
{
Response.Write(ex);
}


}

Thanks
Ranjith.S

Happy Coding

No comments:

Post a Comment

use ful links

Your Ad Here