Hi,
I am getting all the list of site collection information with url and size as a attachment,but i want to get this information as body instead of attached document.
Here is my code.
$SiteCollurl = @{Expression={$_.url};Label="Site Collection URL"}$size = @{Expression={[math]::round($_.diskused/1MB, 2)};label="Size in MB"}
$1stcontact = @{Expression={$_.OwnerLoginName};Label="Primary Contact"}
$2ndcontact = @{Expression={$_.SecondaryContactLoginName};Label="Secondary Contact"}
Get-SPSiteAdministration -Limit All | select $SiteCollurl, $size, $1stcontact, $2ndcontact | Sort-Object -Descending -Property “Size in MB” | ConvertTo-Html -title “Site Collections sorted by size” | Set-Content C:\sitecollectionsizes.html
$file = "C:\sitecollectionsizes.html"
$EmailFrom = "abc@gmail.com"
$EmailTo = "xyz@gmail.com"
$SMTPServer = "smtp server name"
$EmailSubject = "Sitecollection Monitoring Result"
$att = new-object Net.Mail.Attachment($file)
#Send mail with output
$mailmessage = New-Object system.net.mail.mailmessage
$mailmessage.from = ($EmailFrom)
$mailmessage.To.add($EmailTo)
$mailmessage.Subject = $EmailSubject
$mailmessage.Body = "Please find the attached list of Site Collection's "
$mailmessage.IsBodyHTML = $true
$mailmessage.Attachments.Add($att)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer)
$SMTPClient.Send($mailmessage)
$att.Dispose()
code is working fine getting the attachment,i am trying to get with proper table structure with in the body with table rows,columns.
Can any please help on this..
Thanks in advance........