I just made a script for somebody which can save the eMail file with a filename from the attachment of it.
Here is it for the case that somebody needs it:
Code: Select all
Import-Module -Name 'C:\Program Files\Somebytes\EEAttachments\Microsoft.Exchange.WebServices.dll'
$item = Get-Variable -Name mailitem -ValueOnly
$psPropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.ItemSchema]::Attachments)
$item.Load($psPropertySet)
$attname = "unknown"
foreach($a in $item.Attachments)
{
if (!($attname.EndsWith("jpg")) -or ($attname.EndsWith("png")))
{
$attname =[IO.Path]::GetFileNameWithoutExtension($a.Name)
}
}
$eml = Get-Variable -Name emlfile -ValueOnly
$emlfile = Get-ChildItem $eml
$newfilename = $emlfile.DirectoryName + "\" + $attname +".eml"
move $eml $newfilename