diff --git a/src/services/himalaya/client.py b/src/services/himalaya/client.py index e98372a..3e05720 100644 --- a/src/services/himalaya/client.py +++ b/src/services/himalaya/client.py @@ -339,11 +339,15 @@ async def search_envelopes( # Himalaya query syntax: from or to or subject or body search_query = f"from {query} or to {query} or subject {query} or body {query}" - cmd = f"himalaya envelope list -o json -s {limit} {search_query}" + # Build command with options before the query (query must be at the end, quoted) + cmd = "himalaya envelope list -o json" if folder: cmd += f" -f '{folder}'" if account: cmd += f" -a '{account}'" + cmd += f" -s {limit}" + # Query must be quoted and at the end of the command + cmd += f' "{search_query}"' process = await asyncio.create_subprocess_shell( cmd,