2016-04-06 22 views
-1

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 kaybeder
Following 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. 

:

enter image description here

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(); 
+0

Kodunuz nerede? – Eser

+0

Üzgünüz @Eser Eklemedim, üzgünüm –

cevap

0

"\ r \ n" yerine "\ n" senin satır dizisi olarak:

Bu benim kodudur.

+0

bu çözümü denedim, aynı sorunu yaşıyorum. –

+0

Ardından sorun, alıcı istemcinin yanlış oluşturmasıdır. – jstedfast

+0

Bu sorunun yalnızca şu satırda olduğunu buldum: BodyMessage.Append ((index + 1) + "." + LocalFiles [index] + "- Record Count:" + File.ReadLines (LocalFiles [index]). Sayı() + "\ n"); Olup olmayan başka bir satır ile ve iyi biçimlendiriyor –