/// <summary> /// Gets all flags. /// </summary> /// <param name="uid">The uid.</param> /// <param name="streamOperator1">The stream operator1.</param> /// <returns></returns> /// <exception cref="ImapException"></exception> private async Task <List <string> > GetFlags(string uid, StreamOperator streamOperator1) { var result = new List <string>(); try { var response = await streamOperator1 .ReceiveResponse( $"$ UID FETCH {uid} (FLAGS)", s => s.Contains("$ OK") || s.Contains("$ BAD") || s.Contains("$ NO")); var regex = new Regex(@"\\(\w*)"); var matches = regex.Matches(string.Join(" ", response)); foreach (Match item in matches) { result.Add(item.Value); } } catch (Exception e) { throw new ImapException(e.Message); } return(result); }
// last line identifier is common for all SMTP requests unlike IMAP private async Task <List <string> > ReceiveResponse(string request) { return(await _streamOperator.ReceiveResponse(request, s => true)); }