emialセットアップクラスを使用して、メール本文にアイテムのリストを入力しようとしています。Outlookでメールを開こうとすると、アイテムのリストを期待しているアイテムが1つだけ表示されます。
以下は私のコードです:
public class EmailSetup
{
string toEmailSetup = string.Empty;
string fromEmailSetup = string.Empty;
string domainName = string.Empty;
string emailServer = string.Empty;
public void ApplicationFailedEmailSetup(List<string>ApplicationsInactive,DateTime dateRun)
{
toEmailSetup = ConfigurationManager.AppSettings["To mailid"];
fromEmailSetup = ConfigurationManager.AppSettings["From mailid"];
domainName = ConfigurationManager.AppSettings["Domain Name"];
emailServer = ConfigurationManager.AppSettings["Email Server"];
try
{
var messager = new MailMessage();
messager.To.Add(toEmailSetup);
messager.Subject = "Applications Crashed/Closed";
messager.From = new MailAddress(fromEmailSetup);
try
{
messager.Body = "Following applications you are monitoring are closed are crashed:";
**foreach (var item in ApplicationsInactive)
{
messager.Body = item;
}** // Here i am trying to populate list of applications.
}
catch (Exception)
{
throw;
}
var smtp = new SmtpClient(emailServer);
smtp.EnableSsl = true;
try
{
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Send(messager);
}
catch (Exception)
{
throw;
}
}
catch (SmtpException ex)
{
throw new ApplicationException
("SmtpException has occured: " + ex.Message);
}
}
}