The guest's lock code can be added to a message rule as a message tag. From the “Insert tags” drop down menu below the message box you can choose the "Guest's Lock Code" tag
This will automatically fill in the guest's code (last 4 digits of their phone number) for that specific reservation.