I have a Powershell script to send emails with zipped files as an attachment. On the server, the zip files are about 16MB. Those emails are rejected by our Exchange server because the attachment is too big. We have 20MB limit. The Exchange server shows the attachments as 21MB. What could be the reason for that?
This is the script:
$baseDir = "\\999.999.999.999\xxxxx\yyyy"
#email settings
$MailServer = "mail.#######.com"
$eMailSender = 'xxx@######.com'
$Recipient = 'yyy@######.com'
$Subject = "Files available"
$BodyBase = "Hello,`n`nattached are the files`n"
$zipFileBaseName = "xyzfiles" + (Get-Date).ToString("yyyyMMdd")
$zipFiles = $baseDir + "\" + $zipFileBaseName + "*"
$NumZips = (Get-ChildItem $zipFiles).count
$i = 0
foreach($zip in Get-ChildItem $zipFiles)
{
$i++
$Body = "This is email " + $i + " of " + $NumZips + ". (" + $zip.Name + ")"
$Body = $BodyBase + $Body
Send-MailMessage -SmtpServer $MailServer -from $eMailSender -To $Recipient -Subject $Subject -Body $Body -Attachments $zip.Fullname
}
The number of zip files in the folder is different every day. Sometimes the size is just about 10MB. In this case, the email is sent.
Any ideas what adds 5MB to the attachments?
Thanks,
Michael