We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ImapClient.FetchMessage with multithreading throws InvalidOperationException

this is code

var _DB = new DBContext(@“data source=(localdb)\MSSQLLocalDB;initial catalog=dbtsyncxx; integrated security=True ;”);
ProjectEntity Pro = _DB.Projects
.Include(Q => Q.MigrationConfig)
.Include(Q => Q.Users.Select(u => u.MailFolders.Select(mf => mf.MailMessages)))
.Include(Q => Q.UserFolderMappings).Include(q => q.Users.Select(u => u.UserFolderMappings))
.Include(Q => Q.SourceEndPoint)
.Include(Q => Q.TargetEndPoint).First();
Aspose.Email.Clients.Imap.ImapClient ImapClient = new Aspose.Email.Clients.Imap.ImapClient
{
Host = “”,
Username = “”,
Password = “”,
Port = 993,
Timeout = 60 * 60 * 1000
};
// Aspose.Email.Clients.IConnection com = ImapClient.CreateConnection(true);
foreach (MigrationToolBox.DBContext.Entity.MailFolderEntity item in Pro.Users[0].MailFolders)
{
foreach (MailMessageEntity itmaiem in item.MailMessages)
{
Task.Run(() =>
{
try
{
MailMessage xx = ImapClient.FetchMessage(itmaiem.UniqueID);

                    }
                    catch (Exception ex )
                    {

                      
                    }

                });
            }
        }
        Console.Read();

Aspose.Email version=20.12.0
with this code i got error Exception system.invalidoperationexception in aspose.mail.dll Message : “{08DA9AE2-B333-4C77-A7E3-070F23627822}:114”

if i set UseMultiConnection = Aspose.Email.Clients.MultiConnectionMode.Enable and use another connection (what ever CreateConnection(true/fasle )) for fetchmessage i got the same error
how can i fetch message with multithreading

@strikene,
Welcome to our community! Thank you for posting the query. There were many updates after version 20.12. Please check the issue using the latest version of Aspose.Email. If the issue persists, please isolate the problem and share a comprehensive code example or a simple standalone project (your code snippet contains unknown classes).