Quantcast
Channel: ImapX 2
Viewing all 1952 articles
Browse latest View live

New Post: Walking thrue lot of e-mails in folder

$
0
0
Hi Pavel,
I forgot to kindly ask you for sending compiled DLL (4 or 4.5).
So be so kind - thanks.
Miroslav

New Post: Walking thrue lot of e-mails in folder

Source code checked in, #34707

$
0
0
- Added support for WinRT, (Warning: Saving of files not available yet!)

New Post: Walking thrue lot of e-mails in folder

$
0
0
Hi Pavel,

thanks a lot.

It seems it is working perfect!!

Miroslav

New Post: Mark as read and moving

$
0
0
Hi,
First to all, excellent work, thx for sharing to all!

I have reading and moving from inbox to XXX folder but message not delete easly.

First question, why MoveTo renamed to CopyTo and MoveTo implements Remove. ¿?

¿How can improve my code?
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

New Post: Mark as read and moving

$
0
0
Hi Fastorro,

the method Message.CopyTo creates a copy of the message in the specified folder. The method Message.MoveTo however, creates a copy of the message in the specified folder, and then deletes it from the current folder. The methods do exactly what their names say.

Coming to your question about why the mehod Message.MoveTo uses Message.Remove: The IMAP protocol doesn't provide a way to move messages, only copy, that's why in order to move a message, we need to copy it, and then delete the original one.

I have an idea about improving your code, will post a sample here later.

Greets,

Pavel

New Post: Mark as read and moving

$
0
0
Ok thanks...

then i suggest CopyTo -> Clone() :P

If i move msg i will lose UID?

Thanks by you patience and improve code if you have free time ;)

New Post: How to display a message?

$
0
0
Hello. I apologize for my English.
How to display a message on the screen? And how to find a particular message. For example, under the name of the letter, the sender (... @ oplata.info).
I'm very tired. I can not understand.
    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;
        }

    }

New Post: Mark as read and moving

$
0
0
Hi Fastorro,

at the moment the UID is getting lost on move, however, it is a bug. If the server supports the UIDPLUS extension, then it will be possible to retrieve the UID. Just wait for the coming release, I will provide a fix for this.

About renaming CopyTo to Clone: For me, Clone would mean creating a copy of the message in same folder. The method CopyTo however, can create copies in other folders too.

New Post: How to display a message?

$
0
0
Hi jallvar,

first of all, feel free to contact me in Russian through mail: p13a92@gmail.com

A small remark on your code

I recommend setting client.Behavior.AutoPopulateFolderMessages to true before connecting. This will keep your code clean, doing all major configuration of the client in one place.

Searching for messages

The general information on searching for messages can be found in the documentation. If you like to perform a search by the subject of the message, or a specific sender, use the following approach:
// 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.
If you like to perform a query with non-ascii characters (e.g subject in russian), use this thread for reference.
In case you are planning to use the library with the servers of mail.ru, please consider that their server implementation is not complete and doesn't allow the use of various search criterias.

Displaying messages

For displaying a message in a Windows Forms project you can use a WebBrowser control. The sample application you can find in the downloads section does the same. This is the approximate code:
// 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,

Pavel

New Post: How to display a message?

Created Unassigned: MessageCollection.Download() crash [1911]

$
0
0
When trying to download a specific email with anything more than just the headers, using

folder.Messages.Download(new long[] { uId });

the app crashes:

The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.Net.Mime.ContentDisposition.get_FileName()
at ImapX.Parsing.BodyStructureParser.ParsePart(Int32 number, Int32 level)
at ImapX.Parsing.BodyStructureParser.Parse(Int32 level)
at ImapX.Parsing.BodyStructureParser.Parse(Int32 level)
at ImapX.Message.TryProcessBodyStructure(String data)
at ImapX.Message.ProcessCommandResult(String data)
at ImapX.ImapBase.SendAndReceive(String command, IList`1& data, CommandProcessor processor, Encoding encoding)
at ImapX.Message.Download(MessageFetchMode mode, Boolean reloadHeaders)
at ImapX.Folder.Fetch(IEnumerable`1 uIds, MessageFetchMode mode)
at ImapX.Folder.Search(Int64[] uIds, MessageFetchMode mode)
at ImapX.Collections.MessageCollection.Download(Int64[] uIds, MessageFetchMode mode)
at XXX

The specific email is an old (Mar 2012) store receipt from the Apple store.

New Post: toEml and save doesn't work

$
0
0
Hi,
I have the same error when using. SaveTo ()
   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")
                .....
Image

Thank you

Commented Unassigned: MessageCollection.Download() crash [1911]

$
0
0
When trying to download a specific email with anything more than just the headers, using

folder.Messages.Download(new long[] { uId });

the app crashes:

The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.Net.Mime.ContentDisposition.get_FileName()
at ImapX.Parsing.BodyStructureParser.ParsePart(Int32 number, Int32 level)
at ImapX.Parsing.BodyStructureParser.Parse(Int32 level)
at ImapX.Parsing.BodyStructureParser.Parse(Int32 level)
at ImapX.Message.TryProcessBodyStructure(String data)
at ImapX.Message.ProcessCommandResult(String data)
at ImapX.ImapBase.SendAndReceive(String command, IList`1& data, CommandProcessor processor, Encoding encoding)
at ImapX.Message.Download(MessageFetchMode mode, Boolean reloadHeaders)
at ImapX.Folder.Fetch(IEnumerable`1 uIds, MessageFetchMode mode)
at ImapX.Folder.Search(Int64[] uIds, MessageFetchMode mode)
at ImapX.Collections.MessageCollection.Download(Int64[] uIds, MessageFetchMode mode)
at XXX

The specific email is an old (Mar 2012) store receipt from the Apple store.
Comments: ** Comment from web user: thapide **

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.

New Post: Error Nullable object have to have value

$
0
0
Hello,

i have this code:
                        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 ....

Would you be so kind to write me, what is wrong?

Thank you
Miroslav

New Post: Message unique identification?

$
0
0
Hello, I try to write e-mail archive utility. So I walk thrue a loop, where I get UID and Internal Date.
I though it should be unique - so I make filename from them and check if such file exists.
If so I don't download message again.

But now I see repeated messages in my archive folder, where internalDate and content are same, but UID is different.

How can I identify already downloaded messages uniquely?

Thank you
Miroslav

New Post: Message unique identification?

$
0
0
Hi Miroslav,

to identify a message uniquely, please use the Message.MessageId property.

If you made any changes to the ImapClient.Behavior.RequestedHeaders property, make sure that it contains MessageHeader.MessageId or is null.

Greets,

Pavel

New Post: Error Nullable object have to have value

$
0
0
Hi Miroslav,

the exception occurs because the Message.InternalDate property doesn't have a value. This is because it is not being fetched at all, as you have made a mistake setting the download mode.

It should be this way:
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.

If you want to know more about it and how you can combine the different values, there is a good article on CodeProject: Understand how bitwise operators work (C# and VB.NET examples)

Greets,

Pavel

New Post: toEml and save doesn't work

$
0
0
Thank you for the reports!

As a temporary fix you can use the Message.DownloadRawMessage method, for details see my answer in this thread.

Best regards,

Pavel

New Post: Message unique identification?

$
0
0
Hi Pavel,
in my case MessageId is null.
How should I do message.download for fill this item?

Additional question - can I do query to message list e.g. not older than 10 days?

Sincerely Miroslav
Viewing all 1952 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>