Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Output in Email Body Formatting Warped

$
0
0

Hi All

I am completly new to powershell & am googling about for code.

I have been able to so far to send the results of a powershell query by email and am mightly impressed it worked.

When the query is done on the command line it works great, by email the output is spread wide and the fields dont align with each other.

I have pasted my commands below. I am querying the Exchange Mailbox sizes and wish to sort by the biggest down.  This works great and I out put it to a text file.

I then read the text file and substitute it for the body of the email.

On the outlook email recepient end It looks to me like the window size of outlook causes the text to wrap around and it is no longer displayed lengthways.

Is there anything I can do?

Thanks

Below gets data

Get-WMIObject -Class Exchange_Mailbox -Namespace ROOT\MicrosoftExchangev2 -ComputerNameMyExchangeServer | Where-Object {$_.LastWriteTime -le (Get-Date).AddYears(1)} | Select-Object MailboxDisplayName,Size| sort-object size -descending

Below tells which exchnage server to use

$psEmailServer = "MyExchangeServer"

Below is the text file containing the data I need assigned to $body

$body= (Get-Content mailboxsize.txt)

Below sends the email using the contents of the email as the email body, BUT it dosent come out right and its out of alignment in outlook.

send-mailmessage -from "my-email@mymail.com" -to "my-email@mymail.com" -subject "test powershell email" -body "$body"

 



confuseis



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>