First log in to Microsoft 365 admin portal at https://admin.microsoft.com/ as an administrator and go to Users screen:

Select an user and on the Mail tab click Manage email apps

Check IMAP, Pop and Authenticated SMTP to turn on the protocols

Have in mind it takes 20-30 minutes for the changes to take effect.
You should be able to login using your primary password, however we advise to use App passwords instead:
using (Imap imap = new Imap())
{
imap.ConnectSSL("outlook.office365.com");
imap.UseBestLogin(
"AdeleV@limilabs.onmicrosoft.com",
"password");
imap.SelectInbox();
List<long> uids = imap.Search(Flag.Unseen);
foreach (long uid in uids)
{
IMail email = new MailBuilder()
.CreateFromEml(imap.GetMessageByUID(uid));
string subject = email.Subject;
}
imap.Close();
}
Exchange administration
You can find the same settings through Exchange administration screens:





The post Office 365 enable IMAP/POP3 and SMTP access first appeared on Blog | Limilabs.