Organize your mails or attachments!
In this tutorial shows you how you can organize your attachments or mailcontent in a folder structure.
I am using a PowerShell script to bring the EEAttachments export in a form like [/from-address/subject/file]
In my case i run the PowerShell from EEAttachments with this command "C:\Windows\System32\WINDOWSPOWERSHELL\v1.0\powershell.exe" .
The arguments are:
-executionpolicy bypass -file c:\temp\process.ps1 %from% %file% %subject%
The mainpart here is the script process.ps1 and the parameters for it. %from% as the from-mailaddress, %file% path to the exported file, %subject% as mail-subject. The mail-address and subject should later be the directoryname.
After the export of the file, we want to have a folder structure like:
C:\Path\from-mail-address\subject\filename
The scriptfile (process.ps1) conains the following:
$subject = $args[2] -replace '[:*#?\{\}\/\\|]',''
$outdir = "C:\temp\EEAttachments\"+$args[0]+"\"+$subject+"\"
if(!(Test-Path $outdir))
{
md -Path $outdir
}
Move-Item -Path $args[1] -Destination $outdir
What is the script doing?:
Line 1: Remove bad characters from the subject
Line 2: Create a foldername and save it to $outdir.
Line 3-6: If the folder doesn't exist, create the sub-folder.
Line 7: Move exported file into the sub-folder from line 3-6.