private string SendEmailSMTP(string EmailId, string Subject, string MessageBody)
{
string Confirmation = string.Empty;
try
{
string Subject = Subject; //----Subject of the Mail
string MessageBody = "MessageBody"//--Your Message Body Text Goes Here";
MailMessage Mail = new MailMessage();
MailAddress fromAddress = new MailAddress("FromAddress@someexample.Com");
Mail.From = fromAddress;
Mail.To.Add(EmailId);//-----To Mail Address
Mail.Subject = Subject;
Mail.Body = MessageBody;
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Host = "00.00.0.000"; //---Host Address Goes Here
SmtpServer.Port = 25;
SmtpServer.Credentials = new NetworkCredential("YourUserName", "YourPassword");
Mail.IsBodyHtml = true;
SmtpServer.Send(Mail);
Confirmation = "1";
}
catch
{
Confirmation = "0";
}
return Confirmation;
}
{
string Confirmation = string.Empty;
try
{
string Subject = Subject; //----Subject of the Mail
string MessageBody = "MessageBody"//--Your Message Body Text Goes Here";
MailMessage Mail = new MailMessage();
MailAddress fromAddress = new MailAddress("FromAddress@someexample.Com");
Mail.From = fromAddress;
Mail.To.Add(EmailId);//-----To Mail Address
Mail.Subject = Subject;
Mail.Body = MessageBody;
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Host = "00.00.0.000"; //---Host Address Goes Here
SmtpServer.Port = 25;
SmtpServer.Credentials = new NetworkCredential("YourUserName", "YourPassword");
Mail.IsBodyHtml = true;
SmtpServer.Send(Mail);
Confirmation = "1";
}
catch
{
Confirmation = "0";
}
return Confirmation;
}
No comments:
Post a Comment