Custom Flags Generated with ImapMessageFlag.Keyword Method Contains Extra Flags

Hi,

I faced an issue with custom flags. This issue is reproduced with Aspose.Email for .NET 21.6.
Working with Message Flags on Server | Documentation (aspose.com)

When I try to create flag with ImapMessageFlag.Keyword() it will return more flags than was expected after more than 23 different keywords is created. See log output (CustomKeyword-log.zip (3.3 KB)
) that is generated by code bellow. After 23 different keywords were generated, then ImapMessageFlag.Keyword() will return also “Seen” flag (24: Answered, 25: Flagged, 26: Deleted, …), and therefore HasFlag will return True if message is read at mail server.
Also some strange behavior at with that same 23 log with inf.Flags prints Before and After. Seems like flag is added to messageInfo even tough my code does not add it. If I include now out commented part (AddMessageFlags) then obviously we have an issue as flag variable can contain not wanted flags and those are added to messages in mail server.
If I remove Guid.NewGuid() part from custom flag then everything works as expected. Seems like generating many different custom flags with Keyword function will overflow to somewhere.

Preconditions in GMail:
- Create folder/label TestFolder
- Send a message to your mail
- Move message to TestFolder
- Read message (to add Seen flag)

ImapClient client = new ImapClient(
		"imap.gmail.com", 993, /*add your credentials*/ );
client.CreateConnection( true );
client.SelectFolder( "TestFolder" );

// Repeat 100 times.
for( int i = 1; i <= 100; i++ )
{
	// Get messages.
	ImapMessageInfoCollection messageInfos = client.ListMessages();
	foreach( var inf in messageInfos )
	{
		Console.WriteLine( $"Before: {inf.Flags}" );

		// Create new flag and check if it is in the message.
		var flag = ImapMessageFlags.Keyword( $"MyCustomFlag-{Guid.NewGuid()}" );
		bool hasFlag = inf.Flags.HasFlag( flag );
		Console.WriteLine( $"{i}: {hasFlag}: {flag}" );
		Console.WriteLine( $"After: {inf.Flags}" );
		Console.WriteLine();
		//if( ! hasFlag )
		//	client.AddMessageFlags( inf.UniqueId, flag );
	}
}

@M-Files_Support

We need to investigate this issue further on our end and a ticket with ID EMAILNET-40303 has been created to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

The issues you have found earlier (filed as EMAILNET-40303) have been fixed in this update.

1 Like

Thanks for a new version.
I just tested that (Email for .NET 21.9) and there are still some strange behavior. Now line-by-line example code works, but if I include commented out code (AddMessageFlags) part, then this is broken after 58 rounds of that for loop. Then inf.Flags.HasFlag function will return true even that is just generated truly new GUID.
Can you verify, do you have same result when you include if( ! hasFlag ) client.AddMessage() -part?

@M-Files_Support,
I reproduced the problem with new flags starting the 58th round and logged the issue with ID EMAILNET-40436 in our tracking system. Our development team will investigate this case. You will be notified when the problem is resolved.

Hi,
We have just escalated the remaining issue in Enterprise Support: Containerize.IdentityServer - Single sign-on to access all applications and services of Aspose Pty Ltd.

Best Regards,
Mika Rantanen

@M-Files_Support,

I see that the issue priority is changed to “Enterprise Support”. Thanks. We are already working on the issue. We will notify you as soon as it is resolved.

The issues you have found earlier (filed as EMAILNET-40436) have been fixed in this update.