dzięki za podpowiedź jeszcze tylko chciałem korzystając ze sposobności może pokazać kod metody
generalnie nie wiem jaką mam podać frazę dla poszukiwania
( podawałem kolejno następujące frazy:
Kopiuj
Console.Write("Search String:");
string sSearch = "temat";// Odbierz";// Odebrane";// Główna";// Poczta";// Computerworld";// Console.ReadLine();
//
string [] saSearchData = new String[1];
saSearchData[0] = sSearch;
//
ArrayList saArray = new ArrayList();
//
oImap.SearchMessage(saSearchData,false,saArray);
// SearchMessage: Można wyszukiwać wiadomości. Powróci UID wiadomości. Np Od rjoshi.
//
poniżej jest pełny kod metody
Kopiuj
public void SearchMessage(string [] asSearchData, bool bExactMatch, ArrayList asSearchResult)
{// Search the messages by specified criterias
if (!m_bIsLoggedIn)
{// m_bIsLoggedIn = true
try
{
Restore(true);
}
catch (ImapException e)
{
if (e.Type != ImapException.ImapErrorEnum.IMAP_ERR_INSUFFICIENT_DATA)
throw e;
//
throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_NOTCONNECTED);
}
}
if (!m_bIsFolderSelected && !m_bIsFolderExamined)
{
throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_NOTSELECTED);
}
int nCount = asSearchData.Length;
// nCount = 1
if (nCount == 0)
{
throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_INVALIDPARAM);
}
//--------------------------
// PREPARE SEARCH KEY/VALUE
//
string sCommandSuffix = "";
//
foreach (string sLine in asSearchData)
{// sLine.Length = 7 znaków dla podanej frazy: Odbierz
if (sLine.Length == 0)
{
throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_INVALIDPARAM);;
}
//
// convert to lower case once for all
sLine.ToLower();
// sLine = "Odbierz"
//
if (sCommandSuffix.Length > 0)
sCommandSuffix += " ";
sCommandSuffix += sLine;
}// sCommandSuffix = "Odbierz"
//
ImapResponseEnum eImapResponse = ImapResponseEnum.IMAP_SUCCESS_RESPONSE;
string sCommandString = IMAP_SEARCH_COMMAND + " " + sCommandSuffix;
// sCommandString = "UID SEARCH Odbierz"
sCommandString += IMAP_COMMAND_EOL;
// sCommandString = "UID SEARCH Odbierz\r\n"
ArrayList asResultArray = new ArrayList();// chyba tutaj mmiałby dopisywać do listy znalezionych ( nagłówków ) wiadomości...
//
try
{
//-----------------------
// SEND SEARCH REQUEST
eImapResponse = SendAndReceive(sCommandString, ref asResultArray);
// eImapResponse = IMAP_FAILURE_RESPONSE
if (eImapResponse == ImapResponseEnum.IMAP_SUCCESS_RESPONSE)
{
//-------------------------
// PARSE RESPONSE
nCount = asResultArray.Count;
bool bResult = false;
string sPrefix = IMAP_UNTAGGED_RESPONSE_PREFIX + " ";
sPrefix += IMAP_SEARCH_RESPONSE;
//
foreach (string sLine in asResultArray)
{
int nPos = sLine.IndexOf(sPrefix );
if (nPos != -1)
{
nPos += sPrefix.Length ;
string sSuffix = sLine.Substring(nPos);
sSuffix.Trim();
string [] asSearchRes = sSuffix.Split(' ');
//
foreach (string sResultLine in asSearchRes)
{
asSearchResult.Add(sResultLine);
}
bResult = true;
break;
}
}
if (!bResult)
{
throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_SEARCH, sCommandSuffix);
}
}
else
throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_SEARCH, asResultArray[0].ToString());
}
catch (ImapException e)
{// tutaj wlazł 2017-01-21-2306 dla podanej frazy: Odbierz
LogOut();
throw e;
}
}
//
zwraca mi w oknie konsoli
taki sam tekst komunikatu
poniżej wydruk szeregu otrzymanych komunikatów różniących się zadaną frazą dla powyższej metody ( skopiowane z okna konsoli )
Input :[11]3
Search String:WP.PL
IMAP004 UID SEARCH WP.PL
IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument WP.PL
IMAP005 LOGOUT
- BYE Logging out
IMAP005 OK Logout completed.
Error:Failure searching IMAP with the given criteria. IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument WP.PL:
ani dla frazy: WP
Input :[11]3
Search String:wp
IMAP004 UID SEARCH wp
IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument WP
IMAP005 LOGOUT
- BYE Logging out
IMAP005 OK Logout completed.
Error:Failure searching IMAP with the given criteria. IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument WP:
Input :[11]3
Search String:IMAP004 UID SEARCH Computerworld
IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument COMPUTERWORLD
IMAP005 LOGOUT
- BYE Logging out
IMAP005 OK Logout completed.
Error:Failure searching IMAP with the given criteria. IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument COMPUTERWORLD:
Input :[11]3
Search String:IMAP004 UID SEARCH Poczta
IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument POCZTA
IMAP005 LOGOUT
- BYE Logging out
IMAP005 OK Logout completed.
Error:Failure searching IMAP with the given criteria. IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument POCZTA:
Input :[11]3
Search String:IMAP004 UID SEARCH Główna
IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument G??WNA
IMAP005 LOGOUT
- BYE Logging out
IMAP005 OK Logout completed.
Error:Failure searching IMAP with the given criteria. IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument G??WNA:
Input :[11]3
Search String:IMAP004 UID SEARCH Odebrane
IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument ODEBRANE
IMAP005 LOGOUT
- BYE Logging out
IMAP005 OK Logout completed.
Error:Failure searching IMAP with the given criteria. IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument ODEBRANE:
Niepowodzenie przeszukujące IMAP z danymi kryteriami. IMAP004 BAD Błąd w rozkazie IMAP UID SEARCH: Nieznany argument ODEBRANE:
Input :[11]3
Search String:IMAP004 UID SEARCH temat
IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument TEMAT
IMAP005 LOGOUT
- BYE Logging out
IMAP005 OK Logout completed.
Error:Failure searching IMAP with the given criteria. IMAP004 BAD Error in IMAP command UID SEARCH: Unknown argument TEMAT: