Originally Posted by
omahaNative_1023
the constant takes memory and sits unused when the session is running.
This is not correct. The constant will use memory only when senderIsBad is called and loaded onto the stack. It does not use heap memory.
Look at the big picture. You are worried about memory performance of subs and functions that take milliseconds to run and take up negligible memory. The string takes up 352 bytes. Nobody worries about 352 bytes when system memory is measured in GB.
Second, how frequently do you receive email? Unless you are getting hundreds of emails a minute, you will not see any advantage to further optimization of this code. What performance problem are you trying to solve?
You are searching for each word of the subject to occur anywhere in a string. It is not matching "on", it is matching "a". The word "a" occurs in your string many times. (This will also happen with basic, dot, word, act, work, etc.) To fix this, you must match on entire words. Add a comma at the beginning and end of the test string, and then search for words beginning and ending with a comma.
Also "l" is a really bad variable name because a(l) looks like a(1) in the VBA window.
Bookmarks