Cześć.
Mam problem chyba z niepoprawnym parametrem podawanym do metody Delete Massage
którą chciałbym użyć do usuwania wiadomości z serwera pocztowego
oto kod obiektu z wykomentowaną linią użycia metody DeleteMessage() której nie mogę uruchomić aby skutecznie usunęła mi jakąś wiadomość na serwerze pocztowym:
private static IEnumerable<MailMessage> GetMessages()
{
using (ImapClient client = new ImapClient(imapHost, 993, true))
{
Console.WriteLine("Connected to " + imapHost + '.');
//
// Login
client.Login(imapUser, imapPassword, AuthMethod.Auto);
Console.WriteLine("Authenticated.");
//
// Get a collection of all unseen messages in the INBOX folder
client.DefaultMailbox = "INBOX";
//
IEnumerable<uint> uids = client.Search(SearchCondition.Seen());//.Unseen());
// Seen: 77 new email message(s).
int asd = uids.Count();
//
if (uids.Count() == 0)// ano rzeczywiście tutaj jest com sobie powyżej niby że odkrył... trochę że se pogłówkować musiał byl...
return null;
//
// client.DeleteMessage(uids);// 3);//,"INBOX");
//
return client.GetMessages(uids);
}
}
oto kod z projektu biblioteki ( www.S22.Imap 3.6.0 na Nuget - Libraries.io.html - www.Torben Könke (smiley22) - Libraries.io.html )
/// <summary>
/// Deletes the mail message with the specified UID.
/// </summary>
/// <param name="uid">The UID of the mail message to delete.</param>
/// <param name="mailbox">The mailbox the message will be deleted from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <exception cref="BadServerResponseException">The mail message could not be deleted. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="MoveMessage"/>
public void DeleteMessage(uint uid, string mailbox = null) {
DeleteMessages(new HashSet<uint>() { uid }, mailbox);
}
/// <summary>
/// Deletes the mail messages with the specified UIDs.
/// </summary>
/// <param name="uids">An enumerable collection of UIDs of the mail messages to delete.</param>
/// <param name="mailbox">The mailbox the messages will be deleted from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <remarks>When deleting many messages, this method is more efficient than calling
/// <see cref="DeleteMessage"/> for each individual message.</remarks>
/// <exception cref="ArgumentNullException">The uids parameter is null.</exception>
/// <exception cref="ArgumentException">The specified collection of UIDs is empty.</exception>
/// <exception cref="BadServerResponseException">The mail messages could not be deleted. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="MoveMessages"/>
public void DeleteMessages(IEnumerable<uint> uids, string mailbox = null) {
AssertValid();
uids.ThrowIfNull("uids");
string set = Util.BuildSequenceSet(uids);
lock (sequenceLock) {
PauseIdling();
SelectMailbox(mailbox);
string tag = GetTag();
string response = SendCommandGetResponse(tag + "UID STORE " + set +
@" +FLAGS.SILENT (\Deleted \Seen)");
while (response.StartsWith("*"))
response = GetResponse();
ResumeIdling();
if (!IsResponseOK(response, tag))
throw new BadServerResponseException(response);
}
}
wielkie dzięki za podpowiedź głównie jaką wartość miałbym podać w metodzie DeleteMessage() aby skutecznie usunięta została wiadomość np. numer 3
Remiq