I would try running this in DEBUG with some IF...THEN & TRY...CATCH blocks as well as some Breakpoints to see what path you are actually following.
string Mailserver = "imap.abc.com";
int MailServerPort = 993;
string MailServerUsername = "sumit@abc.com";
string MailServerPwd = "Password";
try {
var client = new ImapX.ImapClient("imap.abc.com", 993, true);
if (!client.Connect()) {
} else {
if (!client.Login(MailServerUsername, MailServerPwd)) {
} else {
}
}
} catch (Exception ex) {
}
Documentation
https://imapx.org/docs/wikipage%20(1).html[
^]