Error selecting a message with index

Hi Support,

I have updated the DLL to the latest one and now I am getting error "Cannot retrive message in 100ms" at the below line.

Aspose.Email.Mail.MailMessage ProcessMessage = MailClient.FetchMessage(ProcessIndex);

Please Help.

Cheers,

ValuePRO

Hi Piers,


We are sorry for any inconvenience caused to you.

Could you please tell us in what context are you using FetchMessage? i.e. with Pop3, Imap or Exchange Server? We’ll try to assist you further as soon as possible.

Hi Support,

I am using Aspose.Email.Imap.ImapClient

Cheers,

Mani

Hi Piers,

Thank you for the additional information.

I tested this issue at my end using the latest version of Aspose.Email for .NET 2.8.0 and the following code. Unfortunately, I was unable to observe this issue at my end and the code worked well. If you are trying different code than this, I would request you to please provide us with your sample code.

In case the below code sample is what you are trying at your end, I would request you to please provide us with a test account at your server with its credentials, so that we can try to reproduce this issue at our end and provide further assistance.

Sample Code:

Aspose.Email.Imap.ImapClient
imap = new Aspose.Email.Imap.ImapClient(“[imap.gmail.com](http://imap.gmail.com/)”,
993, "username@gmail.com", “password”);

imap.EnableSsl = true; // enable the SSL

imap.SecurityMode = Aspose.Email.Imap.ImapSslSecurityMode.Implicit; // set security mode

imap.Connect(true); // connect and login

// select the Inbox folder

imap.SelectFolder(ImapFolderInfo.InBox);

//gets number of messages in the folder

Console.WriteLine(imap.CurrentFolder.TotalMessageCount + " messages found.");

// get the message info collection

ImapMessageInfoCollection list = imap.ListMessages();

// download each message

for (int i = 0; i < list.Count; i++)

{

Console.WriteLine("Fetching: " + list[i].SequenceNumber);

MailMessage msg = imap.FetchMessage(list[i].SequenceNumber);

}

Hi Support,

Below is the sample code. This was working for the old version DLL and not working for the latest one.

Aspose.Email.Imap.ImapClient MailClient = new Aspose.Email.Imap.ImapClient();
MailClient.Host = Host;
MailClient.Username = Username;
MailClient.Password = Password;
MailClient.Timeout = 100;
bool MailBoxLoginSuccess = false;

for (int i = 0; i < 10; i++)
{
try
{
MailClient.Connect(true);
MailBoxLoginSuccess = true;
break;
}
catch (Exception ex)
{
MailBoxLoginSuccess = false;
}
}

if (!MailBoxLoginSuccess)
{
MailClient = null;
}
else
{
MailClient.SelectFolder(Aspose.Email.Imap.ImapFolderInfo.InBox);

int ProcessStartIndex = 0, ProcessChank = 10, TotalMailCount = MailClient.CurrentFolder.TotalMessageCount;
int ProcessEndIndex = ProcessStartIndex + ProcessChank;

if (TotalMailCount > 0)
{
if (ProcessEndIndex > TotalMailCount)
{
ProcessEndIndex = TotalMailCount;
}

for (int ProcessIndex = 1; ProcessIndex <= ProcessEndIndex; ProcessIndex++)
{
Aspose.Email.Mail.MailMessage ProcessMessage = MailClient.FetchMessage(ProcessIndex);

//other code below
}
}
}

Cheers,

ValuePRO

Hi Piers,


I have tested your code with Aspose.Email for .NET 2.6, 2.7 and 2.8. Following observations are same for all the above mentioned versions.

I kept this timeout value to 100 at my system and it fired timeout at the Connect phase each time in the loop.

Afterwards timeout is set to 1000 and greater values. With this scenario the Connect becomes successful but I receive message “An message couldn’t be fetched within 5000 ms”.

Later I set the timeout value to a random number say 10000. After this setting application worked fine and all the messages are extracted successfully.

As per the implementation, it seems the expected behavior. Could you please increase the timeout value according to the internet and other configurations and try out the sample code again. Please share your findings as it will help us to assist you further.

Hi Support,

Could you let me know how to increase the time out.

Cheers,

ValuePRO

Hi Piers,


You could increase the time out by increasing the value in MailClient.Timeout of your code. It sets the timeout in Milliseconds. So, if you want to set the time out to 1 sec, you need to set it as follow:

MailClient.Timeout = 1000;

Please let us know if we can be of any additional help to you.