using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
namespace MyMail
{
class SendMail
{
SmtpClient objSmtpClient = new SmtpClient();
MailMessage objMailMessage = new MailMessage();
MailAddress objMailAddress;
public SendMail()
{
objSmtpClient.Host = "smtp.gmail.com";
objSmtpClient.Port = 465;
}
public bool Sendmail(string mail_From,string mail_To,string mail_Password,string mail_Subject,string mail_Message)
{
objMailAddress = new MailAddress(mail_From);
System.Net.NetworkCredential objNetworkCredential = new System.Net.NetworkCredential(mail_From, mail_Password);
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.Credentials = objNetworkCredential;
objMailMessage.From = objMailAddress;
objMailMessage.Subject = mail_Subject;
objMailMessage.Body = mail_Message;
objMailMessage.IsBodyHtml = false;
objMailMessage.To.Add(mail_To);
try
{
objSmtpClient.Send(objMailMessage);
return true;
}
catch (Exception e)
{
return false;
}
}
}
}
make necessary changes for the above code.