Bir şeyler yapmaya çalışırken bir gövde mesajı oluşturmak için bir dize oluşturucu kullanıyorum. sorunu dize oluşturucudan değer alıyorum ve bu bir biçimlendirilmiş. Benim dize oluşturucu Örnek:. Net.Mail gövdesi ileti gönderilirken biçimi kaybeder C# .net
StringBuilder nasıl göründüğünü tam olarak, ancak e-posta geldi, aşağıdaki gibi onların biçimini kaybederFollowing files were attached by email:
1. C:\SALASFRI2_20150824094158_ScrubLog.txt - Record Count: 8
2. C:\SALASFRI2_20150824102328_ScrubLog.txt - Record Count: 8
3. C:\SALASFRI2_20150824102516_ScrubLog.txt - Record Count: 8
4. C:\SALASFRI2_20160121125353_ScrubLog.txt - Record Count: 8
5. C:\SALASFRI2_20160121125659_ScrubLog.txt - Record Count: 8
===================================================
Total Files: 5
Please contact your system administrator for any further assitance.
:
bir varsa biliyor musunuz e-postama geldiğinde formatı kaybetme özelliği Muhtemelen kullanmak gerekir
if (Notification.IncludeFileName || Notification.IncludeRecordCount)
{
BodyMessage.Append("Following files were attached by email: \n");
for (int index = 0; index < NumberOfFiles; index++)
{
if (Notification.IncludeFileName && Notification.IncludeRecordCount)
BodyMessage.Append((index + 1) + ". " + LocalFiles[index] + " - Record Count: " + File.ReadLines(LocalFiles[index]).Count() + "\n");
else
BodyMessage.Append((index + 1) + ". " + LocalFiles[index] + File.ReadLines(LocalFiles[index]).Count() + "\n");
}
}
if (Notification.IncludeNumberOfFiles)
{
BodyMessage.Append("\n===================================================\n\n");
BodyMessage.Append("Total Files: " + NumberOfFiles + "\n");
}
BodyMessage.Append("\nPlease contact your system administrator for any further assitance.");
////////////////////END OF SUBJECT AND BODY MAIL MESSAGE VALIDATION
////////............SEND THE ATTACHMENTS THROUGH EMAIL................///////////
try
{
MailMessage Email = new MailMessage();
SmtpClient smtp = new SmtpClient(AppConfiguration.SMTPServer);
Email.From = new MailAddress(AppConfiguration.EmailAddress);
Email.To.Add(protocol.SMTPEmailList);
Email.Subject = EmailSubject;
Email.Body = BodyMessage.ToString();
if (directories.Zip)
Email.Attachments.Add(new Attachment(ZipName));
else
foreach (var attachment in LocalFiles)
{
Email.Attachments.Add(new Attachment(attachment));
}
smtp.Port = AppConfiguration.SmtpPort;
smtp.UseDefaultCredentials = true;
smtp.Send(Email);
Email.Dispose();
Kodunuz nerede? – Eser
Üzgünüz @Eser Eklemedim, üzgünüm –