I have their Office 365 E-Mail and I need to have the Created By and Modified By columns refer to their user.
I've managed to solve it myself
var user = clientContext.Web.SiteUsers; User targetUser = user.GetByEmail(creatorMail); newItem["Author"] = targetUser; newItem["Editor"] = targetUser; newItem.Update(); clientContext.ExecuteQuery();
There's a caveats when you update Author and Editor field in CSOM for SharePoint Online. I had inconsistent results so I wrote my discovery in the article: https://ikmoss.wordpress.com/2019/04/29/issues-when-updating-created-by-and-modified-by-fields-in-sharepoint-online-csom/