The code doesn't go into ThisOutlookSession but an ordinary module (add one and paste it there instead). Because of Outlook security you may have to sign the project for it to work without security prompts (or at all). See
http://www.gmayor.com/create_and_emp...gital_cert.htm.
I do not know if your code will work from Outlook (have you tested it) and am reluctant to try and decipher what it is supposed to do, without knowing what that is initially. Debugging other people's code is frustrating and time consuming.