If you post code, please use the ‘Insert Code’ button. Please and thank you!

What you posted it just one long string and a pain to read, please re-post it correctly formated.

Also, what you are asking for seems fairly simple, have you tested it?

if(-not(test-path $pathToFile)){
    # code to send email
}