As mentioned above, most message properties are read only when accessing incoming & sent items – including Task priority. Attempting to set such properties on a readonly item will result in an exception, which is why the rest of your code does not execute.
TaskPriority can be set for draft & personal messages only. Here is some code…
if (mMsg.BoxType = fgwpersonal) or (mMsg.BoxType = fgwDraft) then mMsg.TaskPriority = 2 end if