Hello,
Could you please help me in writing a code for sending an e-mail in c#...

Regards..

Have you written any code yet? If not do so as we do not do work for you. We are only here to help if you have a problem. So write some code and if you have a specific question or problem post it here with your code and we will try to help you. Otherwise you will need to hire someone to do this work for you.

Sure I worked on it before, but because I am new for c# I faced many problems,

System.Web.Mail.MailMessage message=new System.Web.Mail.MailMessage();
message.From="from e-mail";
message.To="to e-mail";
message.Subject="Message Subject";
message.Body="Message Body";
System.Web.Mail.SmtpMail.SmtpServer="SMTP Server Address";
System.Web.Mail.SmtpMail.Send(message);

for example this code it does not work,,

Try out this code.

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            //message.To.Add("xxxx@gmail.com");
            message.Subject = "Rental Agreement Form";
            message.From = new System.Net.Mail.MailAddress("user@msssoftware.com");
            message.To.Add("xxxx@gmail.com");
            //message.CC.Add("xxxx@gmail.com");
            message.IsBodyHtml = true;
            message.Body = result;
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 25);
            smtp.Host = "localhost";
            smtp.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
            smtp.Send(message);
            Label3.Text = "Mail sent Successfully";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.