/// <summary> /// Create new POP3 connection /// </summary> /// <param name="cancel"></param> /// <returns></returns> public Pop3Client Pop3Client_(CancellationTokenSource cancel) { MailSegment.AllowCert(); Pop3Client Pop3Client__ = new Pop3Client(); Pop3Client__.Connect(Pop3Host, Pop3Port, Pop3Ssl, cancel.Token); Pop3Client__.Authenticate(Login, Password, cancel.Token); return(Pop3Client__); }
/// <summary> /// Create new SMTP connection /// </summary> /// <param name="cancel"></param> /// <returns></returns> public SmtpClient SmtpClient_(CancellationTokenSource cancel) { MailSegment.AllowCert(); SmtpClient SmtpClient__ = new SmtpClient(); SmtpClient__.Connect(SmtpHost, SmtpPort, SmtpSsl, cancel.Token); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. SmtpClient__.AuthenticationMechanisms.Remove("XOAUTH2"); SmtpClient__.Authenticate(Login, Password); return(SmtpClient__); }
/// <summary> /// Create new IMAP connection /// </summary> /// <param name="cancel"></param> /// <param name="InboxReadWrite"></param> /// <returns></returns> public ImapClient ImapClient_(CancellationTokenSource cancel, bool InboxReadWrite) { MailSegment.AllowCert(); ImapClient ImapClient__ = new ImapClient(); ImapClient__.Connect(ImapHost, ImapPort, ImapSsl, cancel.Token); // If you want to disable an authentication mechanism, // you can do so by removing the mechanism like this: ImapClient__.AuthenticationMechanisms.Remove("XOAUTH"); ImapClient__.Authenticate(Login, Password, cancel.Token); ImapClient__.Inbox.Open(InboxReadWrite ? FolderAccess.ReadWrite : FolderAccess.ReadOnly, cancel.Token); return(ImapClient__); }