Folder.AppendMessage() always returns false

Topics: Help requests, Issues
Feb 24, 2015 at 3:10 PM
I'm trying to save a sent message in the imap sent folder but the function AppendMessage() always returns false.

My send function is
private void SendMessage(string to_account, string subject, string body)
{
     /* Create message */
     MailMessage message = new MailMessage();
     message.From = new System.Net.Mail.MailAddress(account, name);
     message.To.Add(new System.Net.Mail.MailAddress(to_account));
     message.Subject = subject;
     message.Body = body;

     try
     {
          /* Send message */
          SmtpClient smtpClient = new SmtpClient(smtpServer, smtpPort);
          smtpClient.Credentials = new System.Net.NetworkCredential(login, password);
          smtpClient.Send(message);

          /* Save message */
          if (Client.Folders.Sent.AppendMessage(message))
          {
               Console.WriteLine("Success!!!");
          }
          else
          {
               Console.WriteLine("Error...");
          }
          message.Dispose();
     }
     catch (Exception e)
     {
          Console.WriteLine("Exception caught in SendMessage(): " + e.ToString());
          throw new Exception(e.ToString());
     }
}
Before calling my sent function I login to imap server like this
if (Client.Connect(imapServer, imapPort, ssl))
{
     if (Client.Login(login, password))
     {
          Console.WriteLine("Connection with Imap Server established");
     }
     else
     {
          Console.WriteLine("Authentication is not correct");
     }
}
else
{
     Console.WriteLine("Impossible to connect to Imap Server");
}
I can't find what is wrong and I can't think in a workaround to solve it. I appreciate any help

Thank you in advance
Coordinator
Feb 27, 2015 at 6:23 PM
Hi MrBrightside,

to solve this issue I will need a log file as described in the dcoumentation. In this way I can analyze the server responses and determine the exact cause for the problem.

Greets,

Pavel
Mar 2, 2015 at 8:55 AM
Thanks for your answer Pavel,

The log file result when I connect to the server, log in, send a test mail and try to append it to "Sent" folder is this one:
IMAPX1 CAPABILITY

* CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID SASL-IR COMPRESS=DEFLATE ACL RIGHTS=kxte QUOTA MAILBOX-REFERRALS NAMESPACE UIDPLUS NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT SORT=MODSEQ THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE CATENATE CONDSTORE SCAN IDLE LISTEXT LIST-SUBSCRIBED X-NETSCAPE URLAUTH AUTH=PLAIN AUTH=LOGIN AUTH=CRAM-MD5
IMAPX1 OK completed
IMAPX2 LOGIN "xxxxxxxxx" "xxxxxxxxx"

IMAPX2 OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID LOGINDISABLED COMPRESS=DEFLATE ACL RIGHTS=kxte QUOTA MAILBOX-REFERRALS NAMESPACE UIDPLUS NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT SORT=MODSEQ THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE CATENATE CONDSTORE SCAN IDLE LISTEXT LIST-SUBSCRIBED X-NETSCAPE URLAUTH] User logged in
IMAPX3 LIST "" %

* LIST (\Noinferiors) "/" "INBOX"
* LIST (\HasNoChildren) "/" "Drafts"
* LIST (\HasNoChildren) "/" "Junk"
* LIST (\HasNoChildren) "/" "Sent"
* LIST (\HasNoChildren) "/" "Trash"
IMAPX3 OK Completed (0.130 secs 6 calls)
IMAPX4 EXAMINE "INBOX"

* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS ()]  
* 444 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1417435632]  
* OK [UIDNEXT 449]  
* OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox
* OK [URLMECH INTERNAL]
IMAPX4 OK [READ-ONLY] Completed
IMAPX5 EXAMINE "Drafts"

* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS ()]  
* 0 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1418123144]  
* OK [UIDNEXT 1]  
* OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox
* OK [URLMECH INTERNAL]
IMAPX5 OK [READ-ONLY] Completed
IMAPX6 EXAMINE "Junk"

* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS ()]  
* 0 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1418123144]  
* OK [UIDNEXT 1]  
* OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox
* OK [URLMECH INTERNAL]
IMAPX6 OK [READ-ONLY] Completed
IMAPX7 EXAMINE "Sent"

* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS ()]  
* 238 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1418123144]  
* OK [UIDNEXT 252]  
* OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox
* OK [URLMECH INTERNAL]
IMAPX7 OK [READ-ONLY] Completed
IMAPX8 EXAMINE "Trash"

* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS ()]  
* 5 EXISTS
* 5 RECENT
* OK [UIDVALIDITY 1418123144]  
* OK [UIDNEXT 6]  
* OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox
* OK [URLMECH INTERNAL]
IMAPX8 OK [READ-ONLY] Completed
Maybe the [READ-ONLY] is the problem?

Greets,

Javier
Mar 10, 2015 at 1:41 PM
Hi Pavel,

Today I have downloaded the last source code and I have used it instead the NuGet build because I was having problems with Idle support in addition to the problem of saving sent emails (idle freezes after a while and I was not able to change NoopIssueTimeout in the nugget build).

At first it wasn't working. The library crashed at StopIdling() waiting for joining _idleLoopThread. Removing the WaitForIdleServerEvents last change ("OK IDLE COMPLETED" To "OK") did the trick and now everything works perfect, both idle and save sent emails.

This may help someone. I hope I have expressed myself well

Thank you for your support and for your great work on this library.

Greets, Javier