How to get a string property by name

I Am using this code to get an int property by name.

bool UMyBPFunctions::GetIntByName(UObject* Target, FName VarName, int& out)
{
    if (Target) 
    {
        FProperty* property = Target->GetClass()->FindPropertyByName(VarName);
        if (!property)
        {
            return false;
        }
        FIntProperty* typedProperty = CastField<FIntProperty>(property);
        if (!typedProperty)
        {
            return false;
        }

        void* propertyAddress = property->ContainerPtrToValuePtr<void>(Target);

        out = typedProperty->GetPropertyValue(propertyAddress);
        return true;
    }
    return false;
}

Does anyone know how I would do the same for an FString?

Just replace the FIntProperty with FStrProperty

https://docs.unrealengine.com/4.27/en-US/API/Runtime/CoreUObject/UObject/FStrProperty/

Thanks so much