Work on vs2010 ,asp.net C#.Recently I work on smtp server.Using the smtp server I need to send mail, I already successfully done this job . To send mail I use the bellow syntax.
public string PostEmail(string mailSubject, string mailBody)
{
string deliveryStatusCode = "Ok";
if (!string.IsNullOrEmpty(mailSubject) && !string.IsNullOrEmpty(gConfig.EmailTo))
{
MailMessage msg = new MailMessage();
msg.To.Add(gConfig.EmailTo);
msg.From = new MailAddress(gConfig.EmailTo);
msg.Subject = mailSubject;
msg.Body = mailBody;
msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient(gConfig.SmtpHost, gConfig.SmtpPort);
smtp.Credentials = new System.Net.NetworkCredential(gConfig.SmtpCredentials, gConfig.SmtpPassword);
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
try
{
smtp.Send(msg);
}
catch (SmtpException smptpEx)
{
deliveryStatusCode = smptpEx.Message;
}
}
else
{
deliveryStatusCode = "Invalid or null value entry.";
}
return deliveryStatusCode;
}
.Now I face one problem,for some reason some mail cannot be sent ,those unsent mail need to be sent ,How to send those unsent mail,Is there any mechanism in smtp to perform this job or there is some way to solve this issue.Thanks in advance .If have any query plz ask.
You can use a pickup directory, if the smpt server is down the mail is not send. When it comes online, it will read the files in the directory and starts sending the emails.