/// <summary> /// Send IDLE command to IMAP server. /// You can receive message from server by register event handler to MessageReceived event of ImapIdleCommand object /// </summary> /// <returns></returns> public void ExecuteIdle(ImapIdleCommand command) { this.ValidateState(ImapConnectionState.Authenticated); this.Send(this.Tag + " IDLE"); var bb = command.GetByteArray(); command.IAsyncResult = this.Stream.BeginRead(bb, 0, bb.Length, this.ExecuteIdleCallback, command); this._State = ImapConnectionState.Idle; }
public ImapConnectionState Open() //Nustato ar esame prisijunge ir grazina connecter/disconnected { if (this.Connect() == true) //Grazina true jei turim socketa sujungta su hosty ir ne null Stream { this._State = ImapConnectionState.Connected; //+ } else { this._State = ImapConnectionState.Disconnected; //+ } return(this._State); //+ }
/// <summary> /// Send Logout command to IMAP server. /// </summary> /// <returns></returns> public ImapCommandResult ExecuteLogout() { this.ValidateState(ImapConnectionState.Authenticated); String s = this.Execute(this.Tag + " Logout"); var rs = new ImapCommandResult(this.Tag, s); if (rs.Status == ImapCommandResultStatus.Ok) { this._State = ImapConnectionState.Connected; } return(rs); }
/// <summary> /// Open connection to a server. /// </summary> public ImapConnectionState Open() { if (this.Connect() == true) { this._State = ImapConnectionState.Connected; } else { this._State = ImapConnectionState.Disconnected; } return(this._State); }
/// <summary> /// Send done command to IMAP server. /// </summary> /// <returns></returns> public ImapCommandResult ExecuteDone(ImapIdleCommand command) { this.ValidateState(ImapConnectionState.Idle); if (command.IAsyncResult != null) { var x = this.Stream.EndRead(command.IAsyncResult); } String s = this.Execute("DONE"); this._State = ImapConnectionState.Authenticated; return(new ImapCommandResult(this.Tag, s)); }
/// <summary> /// /// </summary> /// <returns></returns> public ImapCommandResult ExecuteLogin() { if (this.EnsureOpen() == ImapConnectionState.Disconnected) { throw new MailClientException(); } String commandText = String.Format(this.Tag + " LOGIN {0} {1}", this.UserName, this.Password); String s = this.Execute(commandText); ImapCommandResult rs = new ImapCommandResult(this.Tag, s); if (rs.Status == ImapCommandResultStatus.Ok) { this._State = ImapConnectionState.Authenticated; } else { this._State = ImapConnectionState.Connected; } return(rs); }
private void ValidateState(ImapConnectionState state, Boolean folderSelected) { if (this._State != state) { switch (state) { case ImapConnectionState.Disconnected: throw new MailClientException("You can execute this command only when State is Disconnected"); case ImapConnectionState.Connected: throw new MailClientException("You can execute this command only when State is Connected"); case ImapConnectionState.Authenticated: throw new MailClientException("You can execute this command only when State is Authenticated"); default: throw new MailClientException(); } } if (folderSelected == true && this.CurrentFolder == null) { throw new MailClientException("You must select folder before executing this command." + "You can select folder by calling SelectFolder,ExecuteSelect,ExecuteExamine method of this object."); } }
public ImapCommandResult ExecuteLogin() //Grazina informacija apie atsakyma (ar geras ar ne) ir nustato ImapConnectionState (authenticated / conneceted) { if (this.EnsureOpen() == ImapConnectionState.Disconnected) { throw new MailClientException(); } //Metamas error jei esame disconnected ir negalima prisijungti String commandText = String.Format(this.Tag + " LOGIN {0} {1}", this.UserName, this.Password); String s = this.Execute(commandText); //Ivykdo komanda ir grazina atsakyma ImapCommandResult rs = new ImapCommandResult(this.Tag, s); //Laiko informacija apie atsakyma (ar geras ar ne) if (rs.Status == ImapCommandResultStatus.Ok) //+ { this._State = ImapConnectionState.Authenticated; //+ } else //+ { this._State = ImapConnectionState.Connected; //+ } return(rs); //+ }
private void ValidateState(ImapConnectionState state, Boolean folderSelected) //Meta error jei esame blogame state arba isrinkome neegzistuojanti folderi { if (this._State != state) //+ { switch (state) //+ { case ImapConnectionState.Disconnected: throw new MailClientException("You can execute this command only when State is Disconnected"); //+ case ImapConnectionState.Connected: throw new MailClientException("You can execute this command only when State is Connected"); //+ case ImapConnectionState.Authenticated: throw new MailClientException("You can execute this command only when State is Authenticated"); //+ default: throw new MailClientException(); //+ } } if (folderSelected == true && this.CurrentFolder == null) { throw new MailClientException("You must select folder before executing this command." //+ + "You can select folder by calling SelectFolder,ExecuteSelect,ExecuteExamine method of this object."); //+ } }
private void ValidateState(ImapConnectionState state) { this.ValidateState(state, false); }
/// <summary> /// disconnect connection to IMAP server. /// </summary> public void Close() { this.Socket.Close(); this.Socket = null; this._State = ImapConnectionState.Disconnected; }
/// <summary> /// Send Logout command to IMAP server. /// </summary> /// <returns></returns> public ImapCommandResult ExecuteLogout() { this.ValidateState(ImapConnectionState.Authenticated); ImapCommandResult rs = this.Execute(this.Tag + " Logout"); if (rs.Status == ImapCommandResultStatus.Ok) { this._State = ImapConnectionState.Connected; } return rs; }
/// <summary> /// /// </summary> /// <returns></returns> public ImapCommandResult ExecuteLogin() { if (this.EnsureOpen() == ImapConnectionState.Disconnected) { throw new MailClientException("Connection is not available."); } String commandText = String.Format(this.Tag + " LOGIN {0} \"{1}\"", this.UserName, this.Password); ImapCommandResult rs = this.Execute(commandText); if (rs.Status == ImapCommandResultStatus.Ok) { this._State = ImapConnectionState.Authenticated; } else { this._State = ImapConnectionState.Connected; } return rs; }
/// <summary> /// Send IDLE command to IMAP server. /// You can receive message from server by register event handler to MessageReceived event of ImapIdleCommand object /// </summary> /// <returns></returns> public void ExecuteIdle(ImapIdleCommand command) { this.ValidateState(ImapConnectionState.Authenticated); this.Send(this.Tag + " IDLE"); var bb = command.Buffer; command.IAsyncResult = this.Stream.BeginRead(bb, 0, bb.Length, this.ExecuteIdleCallback, command); this._State = ImapConnectionState.Idle; }
/// <summary> /// Send done command to IMAP server. /// </summary> /// <returns></returns> public ImapCommandResult ExecuteDone(ImapIdleCommand command) { this.ValidateState(ImapConnectionState.Idle); if (command.IAsyncResult != null) { var x = this.Stream.EndRead(command.IAsyncResult); } var rs = this.Execute("DONE"); this._State = ImapConnectionState.Authenticated; return rs; }
/// <summary> /// disconnect connection to IMAP server. /// </summary> public override void Close() { base.Close(); this._State = ImapConnectionState.Disconnected; }
private void ValidateState(ImapConnectionState state) //Meta error jei esame blogame state { this.ValidateState(state, false); //Meta error jei esame blogame state arba isrinkome neegzistuojanti folderi }
/// <summary> /// Open connection to a server. /// </summary> public ImapConnectionState Open() { if (this.Connect() == true) { this._State = ImapConnectionState.Connected; } else { this._State = ImapConnectionState.Disconnected; } return this._State; }