How to set Importance to MapiCalendar Object using Aspose.Email for java API

Hi,
I have to create calendar from MapiCalendar Object. So i have to set Importance to MapiCalendar Object. Please provide me some sample code.

@kharade.a,

Please give a try to following sample code and share the feedback.

public static final byte[] intToByteArray(int value) {
return new byte[] {
(byte)(value >>> 24),
(byte)(value >>> 16),
(byte)(value >>> 8),
(byte)value};
}
private static void testEmail4()
{
byte[] importance = intToByteArray(MapiImportance.Normal);
MapiCalendar cal = new MapiCalendar();
MapiProperty property = new MapiProperty(MapiPropertyTag.PR_IMPORTANCE, importance);
cal.setProperty(property);

}

Hi @kharade.a,

I used your code above to try to set Importance to MapiTasks but it didn’t work.

byte[] b = intToByteArray(MapiImportance.High);
MapiProperty mpImportance = new MapiProperty(MapiPropertyTag.PR_IMPORTANCE, b);
task.setProperty(mpImportance); 

When I use OutlookSpy to see the MapiProperties, it shows this:

PR_IMPORTANCE (0x00170003)
PT_LONG
33554432 (<— I think this value should be 2)

Can you tell me what’s wrong?

Thanks

@kelberuc

I think you have already opened up a ticket with us in following thread. Is this the same issue or different.

Hi @mudassir.fayyaz,

This is a different problem.
The other thread is about creating a whole MapiTask using MimeContent returned from EWS.
This is about only setting the Importance property of a MapiCalendar object.

Thanks

@kelberuc

In that case, please provide the working sample code and source file reproducing the issue so that we may log that in our issue tracking system for investigation.

@mudassir.fayyaz

MapiTask task = new MapiTask();
byte[] bImportance = intToByteArray(MapiImportance.High);
MapiProperty mpImportance = new MapiProperty(MapiPropertyTag.PR_IMPORTANCE, bImportance);
task.setProperty(mpImportance);

@kelberuc

After testing same code using Aspose.Email for .NET 20.9.1 on my end, I can see the value 2 in array as expected.

image.png (31.4 KB)

@mudassir.fayyaz,

I’m afraid this is not the platform we are talking about.
I’m using Aspose Email for Java 20.9 (as mentioned ealier in this thread).

@kelberuc

Using Aspose.Email for Java 20.9 too I am able to get correct values. Please check the attached image.

https://i.imgur.com/xBXOdLy.png

@mudassir.fayyaz,

You changed the intToByteArray() function.
Now it works, thank you very much for your help!

@kelberuc

That’s great it helped you.