public static ImapClient CreateIMapClient(this IMailConnectionInfo connectionInfo)
        {
            var portNumber = connectionInfo.PortNumber == 0
                ? (connectionInfo.Ssl != null && connectionInfo.Ssl.Value) ? 993 : 143
                : connectionInfo.PortNumber;
            var client = new ImapClient();

            if (connectionInfo.Ssl != null)
            {
                client.Connect(connectionInfo.Server, portNumber, connectionInfo.Ssl.Value);
            }
            else if (connectionInfo.Tls ?? false)
            {
                client.Connect(connectionInfo.Server, portNumber, MailKit.Security.SecureSocketOptions.StartTls);
            }
            else if (connectionInfo.TlsWhenAvailable ?? false)
            {
                client.Connect(connectionInfo.Server, portNumber, MailKit.Security.SecureSocketOptions.StartTlsWhenAvailable);
            }
            else
            {
                client.Connect(connectionInfo.Server, portNumber);
            }
            client.Authenticate(connectionInfo.Login, connectionInfo.Password);
            return(client);
        }
Example #2
0
 // public IMapFileValue(IMailConnectionInfo connectionInfo, string folder, string fileName)
 //     : this(connectionInfo, folder, fileName, null, null, null, false) { }
 public MailFileValue(IMailConnectionInfo connectionInfo, string folder, string fileName, string connectorCode, string connectorName, string connectionName, bool setToReadIfBatchDeletion, string mailSubject, DateTime receivedDate, string sender, uint messageId, Dictionary <string, bool> deleted)
     : base(new MailFileValueMetadata
 {
     Server         = connectionInfo.Server,
     Folder         = folder,
     Name           = fileName,
     ConnectorCode  = connectorCode,
     ConnectionName = connectionName,
     ConnectorName  = connectorName,
     MailSubject    = mailSubject,
     ReceivedDate   = receivedDate
 }) => (Name, _messageId, _connectionInfo, _deleted, _folder, _setToReadIfBatchDeletion) = (fileName, messageId, connectionInfo, deleted, folder, setToReadIfBatchDeletion);