Hi Pavel,
I forgot to kindly ask you for sending compiled DLL (4 or 4.5).
So be so kind - thanks.
Miroslav
I forgot to kindly ask you for sending compiled DLL (4 or 4.5).
So be so kind - thanks.
Miroslav
Messages = _mImapClient.Folders["INBOX"].Search().OrderByDescending(_ => _.Date).ToList();
and code: var folderdest = "Reads";
Message msgDel = null;
foreach (var mes in Messages.Where(mes => mes.UId == uid))
{
mes.Seen = true;
foreach (var fld in _mImapClient.Folders["INBOX"].SubFolders.Where(fld => fld.Name == folderdest ))
mes.MoveTo(fld);
msgDel = mes;
}
if (msgDel!=null)
var resultdel = msgDel.Remove(); // <-- don't delete
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void conn_Click(object sender, EventArgs e)
{
getm.RunWorkerAsync();
}
private void getm_DoWork(object sender, DoWorkEventArgs e)
{
var client = new ImapClient("imap.yandex.ru", true);
if (client.Connect())
{
if (client.Login(login.Text, pass.Text))
{
MessageBox.Show("good!");
}
else
{
MessageBox.Show("bad login!");
}
}
else
{
MessageBox.Show("not connected!");
}
ImapX.Collections.FolderCollection folders = client.Folders;
client.Behavior.AutoPopulateFolderMessages = true;
foreach (ImapX.Message m in client.Folders.Inbox.Messages)
{
MessageBox.Show(m.Subject);
//addrow(Convert.ToString(m.From), Convert.ToString(m.Sender), Convert.ToString(m.Subject));
}
}
private int addrow(string adress, string name, string subj)
{
int i = 0;
Invoke(new Action(() => i = listView1.Items.Add(adress).Index));
Invoke(new Action(() => listView1.Items[i].SubItems.Add(name)));
Invoke(new Action(() => listView1.Items[i].SubItems.Add(subj)));
return i;
}
}
// Search all messages containing "@oplata.info" in the FROM field
var messages = client.Folders.Inbox.Search("FROM \"@oplata.info\"");
// Search all messages containing "Test" in subject
var messages = client.Folders.Inbox.Search("SUBJECT \"Test\"");
A full list of available criterias can be found in the specification. // Getting the available body (html is priority, text used if no html body available)
string body = message.Body.HasHtml ? message.Body.Html : message.Body.Text;
// Open a new document in WebBrowser
webBrowser1.Document.OpenNew(true);
// Writing the message body to the document
webBrowser1.Document.Write(message.Body.HasHtml ? body : body.Replace(Environment.NewLine, "<br />"));
Best regards, f.Messages.Download("ALL", ImapX.Enums.MessageFetchMode.Full)
For Each m As ImapX.Message In f.Messages
m.Download(ImapX.Enums.MessageFetchMode.Full, True)
m.SaveTo(Me.txtFolder.Text, m.GMailMessageId & ".eml")
.....
Found the cause.
In BodyStructureParser.cs, ParsePart(int, int), you have the following:
if (part.ContentDisposition != null && string.IsNullOrEmpty(part.ContentDisposition.FileName) && part.ContentDisposition.DispositionType == DispositionTypeNames.Inline)
part.ContentDisposition = null;
part.ContentDisposition is indeed not null, thus part.ContentDisposition.FileName tries to return Parameters["filename"]. The crash happens here because Parameters is actually empty, and it cannot find the requested key.
imapClient.Folders.Inbox.Messages.Download("ALL", Enums.MessageFetchMode.None + Enums.MessageFetchMode.InternalDate, -1)
For Each mx In imapClient.Folders.Inbox.Messages
Try
Dim soubor As String = path & mx.InternalDate.Value.ToString("yyyyMMdd-HHmmss") & "-" & mx.UId.ToString & ".eml"
Console.WriteLine(soubor)
If Not File.Exists(soubor) Then
Dim eml As String = mx.DownloadRawMessage()
File.WriteAllText(soubor, eml)
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
File.AppendAllText("imapArchive.log", Now.ToString("yyyyMMdd-HHmmss ") & ex.Message & vbCrLf)
File.AppendAllText("imapArchive.log", ex.StackTrace & vbCrLf)
End Try
Next
I get error in line Dim soubor As String ....Enums.MessageFetchMode.None Or Enums.MessageFetchMode.InternalDate
Bit flags are used to identify the fetch mode. so you cannot use the + operator to combine them.