We are facing a strange issue while sending email. It seems that the new line is not always working. Our code is
string mailSubject = "EBN Import Success. Client: " + ClientName.Trim();
StringBuilder mailBody = new StringBuilder("Client Name: " + ClientName.Trim());
mailBody.Append(System.Environment.NewLine + "File Name: " + FileName);
mailBody.Append(System.Environment.NewLine + "FileID: " + FileId);
mailBody.Append(System.Environment.NewLine + "BatchID: " + BatchID);
mailBody.Append(System.Environment.NewLine + System.Environment.NewLine + "Records in File (or staging): " + noOfRecords.ToString());
mailBody.Append(System.Environment.NewLine + "Records imported into BNCStaging: " + noOfRecords.ToString());
mailBody.Append(System.Environment.NewLine + "Records imported into EBNTrackings: " + noOfRecords.ToString());
string mailTo = ConfigurationManager.AppSettings["ErrorEmailTo"].ToString();
string mailFrom = ConfigurationManager.AppSettings["EmailFrom"].ToString();
string mailHost = ConfigurationManager.AppSettings["EmailServer"].ToString();
SmtpClient mailClient = new SmtpClient(mailHost);
mailClient.Send(mailFrom, mailTo, mailSubject, mailBody);
The output we are getting is
Client Name: [Client Name]File Name: [File Name]
FileID: nnnn
BatchID: mmmm
Records in File (or staging): x
Records imported into BNCStaging: y
Records imported into EBNTrackings: z
that is the client name and file name are coming in the same line.
We have also tried with AppendLine() and with ‘\n’ without luck.
Any suggestions…
By the way we are using .net 4.0 and the mail client is outlook
In Outlook, click
Extra line breaks in this message were removed, then clickRestore line breaks.