The current code causes a Powershell error that causes 'temp.csv' to never get attached to the email. This is because the first PS line saves temp.csv to the user's home directory, whereas the second PS line tries to attach temp.csv from the system32 folder. I changed the first line to instead save it to system32, which is the default path for an admin Powershell session.
Update Notes:
As this is a longer script, powershell config has changed to lessen the on screen footprint.
Debug "mode" has been added for troubleshooting user settings
User Variables section added with comments
Cred handling moved to securestring as that seems to be more reliable with many smtp providers