title: Email a text file's content in html format
body: <p>I have a text file as:</p>
  
  <p><strong>output.txt:</strong></p>
  
  <pre><code>OPERATING SYSTEM       SERVER1    SERVER2
  Windows                  1.36       4.42
  Linux                    2.78       5.76
  MacOS                    3.45       6.39
  Ubuntu                   4.12       0.00
  Android                  0.00       3.46
  FreePhysicalMemory      30.12      31.65
  TotalVisibleMemorySize  48.00      48.00
  </code></pre>
  
  <p>I want to send content of Output.txt in a email as a body sothat its format (alignment) doesn't get changed (like an HTMIL table format):
  i am trying with below code. Mail sent but in mail body getting nothing..what is error below ?</p>
  
  <pre><code>Const ForReading = 1
  Const ForWriting = 2
  Const ForAppending = 8
  Dim objEmail, i
  Set objEmail = CreateObject("CDO.Message")
  objEmail.Textbody = myTextBody
  objEmail.HTMLBody = myHTMLBody
  If IsArray( myAttachment ) Then
  For i = 0 To UBound( "c:\output.txt" )
  .AddAttachment Replace( "c:\output.txt" ( i ), "" ),"",""
   Next
  ElseIf myAttachment &lt;&gt; "" Then
  .AddAttachment Replace( "c:\output.txt", ""),"",""
  End If
  objEmail.TO ="sunny@abc.com"
  objEmail.From = "dontreply@abc.com (CCP Stored Procedure Message)"
  objEmail.Subject = "CCP Stored Procedure"
  objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration     /sendusing") = 2 
  objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpb.intra.abc.com"
  objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration /smtpserverport") = 25 
  objEmail.Configuration.Fields.Update     
  objEmail.Send
  Set objEmail = Nothing
  </code></pre>
  
  <p><strong>EDIT1</strong></p>
  
  <p>With below code, i am getting email as follows ..</p>
  
  <pre><code>Const ForReading = 1, ForWriting = 2, ForAppending = 8
  Dim fso, f , objCDO1 ,BodyText
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set objCDO1 = CreateObject("CDO.Message")
  BodyText = fso.OpenTextFile("c:\Output.txt",ForReading).ReadAll
  BodyText = "&lt;html&gt;&lt;body&gt;" + BodyText  + "&lt;/body&gt;&lt;/html&gt;"
  objCDO1.HTMLBody = BodyText
  objCDO1.TO ="sunny@abc.com"
  objCDO1.From = "dontreply@bt.com (HFM)"
  objCDO1.Subject = "StatS"
  objCDO1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  objCDO1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpb.abc.com"
  objCDO1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  objCDO1.Configuration.Fields.Update                  
  objCDO1.Send
  Set f = Nothing
  Set fso = Nothing
  </code></pre>
  
  <p><strong>email</strong></p>
  
  <pre><code>OPERATING SYSTEM SERVER1 SERVER2 Windows 1.36 4.42 Linux 2.78 5.76 MacOS 3.45 6.39  Ubuntu 4.12 0.00 Android 0.00 3.46 FreePhysicalMemory 30.12 31.65 TotalVisibleMemorySize  48.00 48.00 
  </code></pre>
  
  <p>why not getting email as output.txt format ?</p>
  
  <p><strong>EDIT2</strong></p>
  
  <p>When I am using below in <strong>EDIT1</strong>..its working.</p>
  
  <pre><code>BodyText = fso.OpenTextFile("c:\Output.txt",ForReading).ReadAll
  objCDO1.HTMLBody = "&lt;html&gt;&lt;body&gt;&lt;pre&gt;" &amp; BodyText &amp; "&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;"
  </code></pre>
  
  <p>But..when I am using below in <strong>EDIT1</strong>..its not working.</p>
  
  <pre><code>BodyText = fso.OpenTextFile("c:\Output.txt",ForReading).ReadAll
  objCDO1.HTMLBody = "&lt;html&gt;&lt;body&gt;&lt;font size="12"&gt;&lt;pre&gt;" &amp; BodyText &amp; "&lt;/pre&gt;&lt;/font&gt;&lt;/body&gt;&lt;/html&gt;"
  </code></pre>