The problem is that the things on either side of the String are not Strings. They are represented as character arrays and you can't use the + operator to concatenate them. You can either make the whole thing with Strings or build the whole thing with char arrays.
If you start with a String then every time you add to it you get a String object.
Be careful though, adding Strings this way can be bad for memory management.
The variable is declared inside the if so it's not accessible outside. If you can't make msgstatic for some reasons, you will have to capture it in the lambda function (actually, it's a better solution than using static) :
I'd flunk a C or C++ class but I mostly use global variables (and local variables) in my Arduino projects... Saves me from having to pass-around values, pointers, & references.
The problem is not about String, it's about the lambda function using a temporary variable. At the time this function will be called, the local variable is gone since a long time, so it needs to be global (or static), or be "captured" by the lambda function.