I downloaded all the messages and checked their attachment . They are filling RAM. I am called that code in threads. I am try to use client.Dispose() and GC.Collect() but is is not helped :((
using (var client = new ImapClient(hostname, true))
{
if (client.Connect( /* optional, use parameters here */ ))
{
// connection successful
if (client.Login(login, pass))
{
// login successful
FolderCollection folders = client.Folders;
int i = 0;
foreach (Folder myfolder in folders)
{
var messages = client.Folders[i].Search("ALL");
i++;
foreach (var message in messages)
{
var attachments = message.Attachments;
if (attachments.Count() > 0)
if (!Directory.Exists(folder + @"\" + login))
{
DirectoryInfo di = Directory.CreateDirectory(folder + @"\" + login);// Try to create the directory.
}
foreach (var attachment in attachments)
{
attachment.Download();
attachment.Save(folder + @"\" + login);
}
}
GC.Collect();
}
}
}
client.Disconnect();
client.Dispose();
}