This project is read-only.

How to create a new message in any folder?

Sep 4, 2013 at 3:53 PM
I am using the example below, but the message is not being created. What am I doing wrong?

Message m = new Message();
MailAddress adr = new MailAddress("Hudson", "hudson@amzsolucoes.com.br"); MessageContent mc = new MessageContent();
mc.TextData = "Message Test from visual studio";
m.To.Add(adr);
m.Subject = "test from visual studio";
m.TextBody = mc;

CreateMessageFolder(m, folder);

public void CreateMessageFolder(Message _NewMsg, Folder _folder)
    {
               _folder.AppendMessage(_NewMsg, ImapFlags.DRAFT);                        
    }
Coordinator
Sep 5, 2013 at 5:57 PM
Hi dinhoguitars,

i will take a look at the code and make a few tests to check if there is any problem. Have you tried appending messages using latest code from repository? There was a fix on this issue some time ago.


Best regards,

Pavel Azanov
Sep 6, 2013 at 8:12 PM
Hello Pavez

I downloaded the latest version of the DLL .. then downloaded the source and found the method in the class ImapBase sendAndReceive had a comment block, this below:

if (text2.StartsWith ("+") &&! ​​command.StartsWith ("UID FETCH"))
{
       flag = false;
}

when uncommented the function worked.
the only problem now is when I add attachment, it's a mistake "startIndex nof found"

ImapX.Message newMsg ImapX.Message = new ();

                     newMsg.Subject = mail.strAssunto;
                     newMsg.From = new ImapX.MailAddress (mail.strNomeOrigem, mail.strOrigem);
                     newMsg.To.Add (new ImapX.MailAddress (mail.strNomeDestinatario, mail.strDestinatario));
                    

                     if (mail.lstCopias.Count> 0)
                     {
                         foreach (string emailEdn in mail.lstCopias)
                             newMsg.To.Add (new ImapX.MailAddress ("" emailEdn));
                     }

                     if (anexosEnvio.Count> 0)
                     {
                         foreach (ImapX.Attachment anex in anexosEnvio)
                         {
                             newMsg.Attachments.Add (annex);
                         }
                     }

                                        
                     newMsg.HtmlBody.TextData = mail.strCorpo;
                     newMsg.Date = DateTime.Now;

                     QryStrings NameValueCollection = Request.QueryString;

                     if (qryStrings ["TP"] == "reply")
                         newMsg.AddFlag (ImapX.ImapFlags.ANSWERED);
                     else newMsg.AddFlag (ImapX.ImapFlags.SEEN);
                                                            

                     AppendMessage (newMsg, Constants.LOCAWEB_ENVIADAS);
Coordinator
Sep 7, 2013 at 9:57 AM
Hi dinhoguitars,

just seen i received a message from you yesterday, I checked your credentials using latest code from repository (not download section) and it works fine. I uploaded the binaries for you:

https://mega.co.nz/#!81lyyIAR!JN4RgjVeGT2x4ImRuq5W3DMyfqpk65WF9CZzhcG65gE

Please use them to see if the problems you mentioned still persist.

Best regards,

Pavel Azanov
Sep 9, 2013 at 12:49 PM
Edited Sep 9, 2013 at 7:20 PM
Hello Pavel, I downloaded the ddl sent
but when I send a new message to add
chamendo AppendMessage the method, the application loops and crashes.

I made this observation in the message by downloading the source and ImapBase going on and take the comment line

if (text2.StartsWith ("+") &&! ​​command.StartsWith ("UID FETCH"))
{
        flag = false;
}

this way the messaging works
Sep 9, 2013 at 7:44 PM
Message newMsg = new Message(imap);
        newMsg.Flags.Add(ImapFlags.SEEN);
        newMsg.Flags.Add(ImapFlags.ANSWERED);


        newMsg.Subject = "Criando mensagem na pasta enviados";
        newMsg.From = new MailAddress("Hudson", "hudson@amzsolucoes.com.br");
        newMsg.To.Add(new MailAddress("Dinho Souza", "dinhoguitars@gmail.com"));
        newMsg.HtmlBody.TextData = "<b>testando</>";
        newMsg.Date = DateTime.Now;
        newMsg.ProcessFlags();


        Folder fd = GetFolder(imap, "INBOX.enviadas");                

            fd.AppendMessage(newMsg, ImapFlags.SEEN);
this time the app is in loop
Coordinator
Sep 9, 2013 at 10:58 PM
Hi dinhoguitars,

please check your mailbox, I sent you the compiled library including a fix for appending messages.


Greets,

Pavel