I'm re-writing a co-worker's VB script. The script runs at login, and pulls in some information about the user account and pulls in some information about the user's account account and whatnot. It then emails this info to an address on our network.
I've got a bit of code that pulls in printer information. The data is supposed to look like this:
Printer Information
-------------------
Current Default Printer: \\ps01\mc-3rdcc-01-ps
All Connected Printers:
Adobe PDF
Send To OneNote 2007
PrimoPDF
Microsoft XPS Document Writer
Microsoft Office Document Image Writer
mc-3rd-cc-02-ps_local
\\ps01\adm-1st-03-ps
\\ps01\mc-3rdcc-01-ps
\\ps01\Xerox
and in fact, it DOES look like that if I display it on the screen via a messagebox.
HOWEVER, it looks like this when it comes in via email:
Printer Information
-------------------
Current Default Printer: \\ps01\mc-3rdcc-01-ps All Connected Printers:
Adobe PDF Send To OneNote 2007 PrimoPDF Microsoft XPS Document Writer Microsoft Office Document Image Writer mc-3rd-cc-02-ps_local \\ps01\adm-1st-03-ps
\\ps01\mc-3rdcc-01-ps
\\ps01\Xerox
Somehow, it's losing the line breaks.
Here's the code behind it:
Function GetPrinterInformation()
Dim retString
Dim strDefault
Dim intCount
Dim colPrinters
retString = "Printer Information" & vbNewLine &_
"-------------------" & vbNewLine
On Error Resume Next
strDefault = objShell.RegRead("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device")
If Err Then
strDefault = "Error reading default printer from the registry"
Err.Clear
End If
On Error Goto 0
retString = retString & "Current Default Printer: " & strDefault & vbNewLine
retString = retString & "All Connected Printers: " & vbNewLine
Set colPrinters = objNetwork.EnumPrinterConnections
For count = 1 to colPrinters.Count -1 Step 2
retString = retString & colPrinters(count) & vbNewLine
Next
retString = retString & vbNewLine & vbNewLine
Set colPrinters = Nothing
GetPrinterInformation = retString
End Function
As you can see, I've got all the vbNewLine stuff in there, and like I said it outputs correctly if I send the output to a messagebox. It just fucks up when I email it out.
Weirder still, I've found that if I change to a different SMTP server, the output looks a little bit better. The printer stuff comes out like it should, but I've got a network adapter area (that also looks fine in the messagebox) that stays screwed up in the email.
Weird.