FetchHeaders failed because your application passed an empty message set. With nothing to fetch, it returned a failed status to alert you.
Ensure your code verifies the success of the `imap.Search` call. If it returns null, inspect `imap.LastErrorText` for details. Additionally, check that all prior IMAP method calls succeeded to rule out earlier failures.
Also, you can check the `Imap.SessionLog` if `Imap.KeepSessionLog` is true. See https://www.example-code.com/csharp/imap_sessionlog.asp