Click here to Skip to main content
15,914,070 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to send email from my web application by using free api or gateway so i want some free api or gateway and code to send mail



C#
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.BodyEncoding = System.Text.Encoding.UTF8;
            mail.From = new System.Net.Mail.MailAddress("somalnitin@gmail.com");
            mail.To.Add("nitinsomal@gmail.com");

            mail.Subject = "my subject";
            mail.Body = "Body";
            mail.Priority = System.Net.Mail.MailPriority.High;
            mail.IsBodyHtml = true;

            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
            smtp.Port = 25;
            smtp.Host = "smtp.gmail.com";
            smtp.Credentials = new System.Net.NetworkCredential("nitinsomal@gmail.com", "mypassword");
            smtp.EnableSsl = true;
            smtp.Send(mail);



I used this but it does not work error comes message sending failed





I m using http://www.shabdar.org/asp-net/111-send-email-from-your-gmail-account-using-aspnet-and-c.html[^]


its not working error: transport layer
Posted
Updated 26-Feb-12 22:32pm
v4
Comments
OriginalGriff 27-Feb-12 4:07am    
And?
What is your problem?
Use the "Improve question" widget to edit your question and provide better information.
Nandakishore G N 27-Feb-12 5:17am    
Even I faced the same..problem...it was because of the Network Configuration...Of the gateway...I worked it using datacard..it worked fine...Try U may find it...
[no name] 27-Feb-12 5:29am    
thanx

Use this Namespace using System.Net.Mail;
C#
MailMessage mail = new MailMessage();
            mail.BodyEncoding = System.Text.Encoding.UTF8;
            mail.From = new MailAddress(from ID);
            mail.To.Add(To ID);
            mail.Subject = strsub;
            mail.Body = strbody;
            mail.Priority = MailPriority.High;
            mail.IsBodyHtml = true;

            SmtpClient smtp = new SmtpClient();
            smtp.Port = 25;
            smtp.Host = "smtp.gmail.com";
            smtp.Credentials = new System.Net.NetworkCredential("Your Mail id", "password");
            smtp.EnableSsl = true;
            smtp.Send(mail);
 
Share this answer
 
v2
C#
MailMessage mail = new MailMessage();
            mail.BodyEncoding = System.Text.Encoding.UTF8;
            mail.From = new MailAddress(from ID);
            mail.To.Add(To ID);
            mail.Subject = strsub;
            mail.Body = strbody;
            mail.Priority = MailPriority.High;
            mail.IsBodyHtml = true;
 
            SmtpClient smtp = new SmtpClient();
            smtp.Port = 25;
            smtp.Host = "smtp.gmail.com";
            smtp.Credentials = new System.Net.NetworkCredential("Your Mail id", "password");
            smtp.EnableSsl = true;
            smtp.Send(mail);
 
Share this answer
 
we can use System.Web.Mail.SmtpMail to send email in dotnet for sneding mail .
have look at this article and go through line by line , if u get any error then try to debug the code line by line first.
Send Email in ASP.Net 2.0 - Feed back Form[^]
 
Share this answer
 

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