Free Support Forum - aspose.com

How to set properties to MapiTask object


#1

Hi Team,
I am working on java and using aspose 18.6 jar for email. Can you please help me for how to set following properties to Mapitask object?
1> Importance
2> Priority
3>MapiCalendarRecurrencePattern for daily, weekly, monthly and yearly for tasks recurrence.


#2

@Rajmohammad

The PR_PRIORITY property can be used to set the priority of a task, as given below:

//Set the URGENT priority
task.setProperty(new MapiProperty(MapiPropertyTag.PR_PRIORITY, BitConverter.getBytesInt64((long)1))); 

For Importance, you may use the following code sample:

int iMapiProperty = 2;//0:LOW, 1:NORMAL, 2:HIGH
MapiProperty prop = new MapiProperty(MapiPropertyTag.PR_IMPORTANCE, BitConverter.getBytesInt32(iMapiProperty));
task.setProperty(prop);

For task recurrence, you may use the following code sample and set MapiCalendarRecurrencePatternType as follows:

	MapiCalendarEventRecurrence recurrence = new MapiCalendarEventRecurrence();
	recurrence.setRecurrencePattern(new MapiCalendarDailyRecurrencePattern());
	
	MapiCalendarRecurrencePattern pattern = recurrence.getRecurrencePattern();
	pattern.setPatternType(MapiCalendarRecurrencePatternType.Day);
	pattern.setPeriod(1);
	pattern.setEndType(MapiCalendarRecurrenceEndType.NeverEnd);

Moreover, please feel free to write back to us if you need additional information.


#3

Hi MuzammilKhan,
Thanks for your reply, I will check this.


#4

Hi Muzammil,
I am trying to set the recurrence in tasks. After exporting this gives me following type of exception please help me for that

class com.aspose.email.system.exceptions.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Not a valid Win32 FileTime.
com.aspose.email.system.DateTime.toFileTimeUtc(Unknown Source)
com.aspose.email.system.DateTime.toFileTime(Unknown Source)
com.aspose.email.MapiProperty.a(SourceFile:1113)
com.aspose.email.MapiProperty.a(SourceFile:1020)
com.aspose.email.MapiMessageItemBase.a(SourceFile:1447)
com.aspose.email.MapiMessageItemBase.a(SourceFile:1463)
com.aspose.email.MapiTask.a(SourceFile:1014)
com.aspose.email.FolderInfo.addMapiMessageItem(SourceFile:802)


#5

@Rajmohammad

It is requested to kindly share your code sample so that we could investigate in detail.


#6

Hi Muzammil,
I have attached the file please check in that the values and sample code is present.
I am working on java and I am using aspose 18.6 jar file of Aspose.Email family.

AsposeForTaskCode.txt.zip (1.2 KB)


#7

@Rajmohammad

We have tried to reproduce the issue but we are unable to do that using Aspose.Email for Java 18.12. Kindly try the following code, we have made few changes in it and share your feedback.

MapiTask f_objMapiTask = new MapiTask();
f_objMapiTask.setActualEffort(0);
f_objMapiTask.setEstimatedEffort(0);
f_objMapiTask.setHistory(0);
f_objMapiTask.setMode(0);
f_objMapiTask.setReminderSet(false);
		
	String RDate = "MAR 29 2018 00:14:00";
        SimpleDateFormat sdRDate = new SimpleDateFormat("MMM dd yyyy HH:mm:ss");
        Date dRDate = sdRDate.parse(RDate);
        
		f_objMapiTask.setReminderTime(dRDate);
		f_objMapiTask.setState(0);
		f_objMapiTask.setSubject("Test Sample");
		f_objMapiTask.setBody("This is test sample for monthly recurrence");
		
		String DueDate = "MAR 29 2018 00:00:00";
        SimpleDateFormat sd = new SimpleDateFormat("MMM dd yyyy HH:mm:ss");
        Date date1 = sd.parse(DueDate);
        
		f_objMapiTask.setDueDate(date1);

		MapiCalendarMonthlyRecurrencePattern 	f_ObjMonthlyRecurrencePattern = new MapiCalendarMonthlyRecurrencePattern();
		f_ObjMonthlyRecurrencePattern.setDay(Integer.parseInt("29"));
		f_ObjMonthlyRecurrencePattern.setPeriod(1);
		f_ObjMonthlyRecurrencePattern.setCalendarType(MapiCalendarRecurrenceCalendarType.Default);
		f_ObjMonthlyRecurrencePattern.setPatternType(MapiCalendarRecurrencePatternType.Month);
		f_ObjMonthlyRecurrencePattern.setEndDate(new Date());
		f_ObjMonthlyRecurrencePattern.setEndType(MapiCalendarRecurrenceEndType.EndAfterDate);
		
		MapiCalendarEventRecurrence recurrence = new MapiCalendarEventRecurrence();
		recurrence.setRecurrencePattern(f_ObjMonthlyRecurrencePattern);
		
		
		MapiProperty f_objMapiProperty = new MapiProperty(MapiPropertyTag.PR_IMPORTANCE, BitConverter.getBytesInt64(1));
		f_objMapiTask.setProperty(f_objMapiProperty);
		f_objMapiProperty = null;
		
		PersonalStorage pst = PersonalStorage.create(dataDir + "TaskPST1_out.pst", FileFormatVersion.Unicode);
		FolderInfo TaskFolderInfo = pst.createPredefinedFolder("Tasks", StandardIpmFolder.Tasks); 

Furthermore, please feel free to write back to us if we have missed something.


#8

Hi Muzammil,
I have checked this code but can you please help me for how to set the MapiCalendarEventRecurrence into MapiTask object.


#9

@Rajmohammad

The setRecurrence() method only takes MapiCalendarRecurrencePattern value as parameter. You can set MapiCalendarMonthlyRecurrencePattern to task like as given below:

    MapiCalendarMonthlyRecurrencePattern 	f_ObjMonthlyRecurrencePattern = new MapiCalendarMonthlyRecurrencePattern();
    f_ObjMonthlyRecurrencePattern.setDay(Integer.parseInt("29"));
    f_ObjMonthlyRecurrencePattern.setPeriod(1);
    f_ObjMonthlyRecurrencePattern.setCalendarType(MapiCalendarRecurrenceCalendarType.Default);
    f_ObjMonthlyRecurrencePattern.setPatternType(MapiCalendarRecurrencePatternType.Month);
    f_ObjMonthlyRecurrencePattern.setEndDate(new Date());
    f_ObjMonthlyRecurrencePattern.setEndType(MapiCalendarRecurrenceEndType.EndAfterDate);
    				
    task.setRecurrence(f_ObjMonthlyRecurrencePattern); 

Moreover, please feel free to write back to us if you have any specific requirements.


#10

Hi MuzammilKhan,
I have to set the completed date to TASK but the completed date is before the start then how to set the completed date because it showing me following error

class com.aspose.email.system.exceptions.ArgumentException: The date completed should be greater than the start date.

com.aspose.email.MapiTask.c(SourceFile:601)

com.aspose.email.MapiTask.setDateCompleted(SourceFile:616)

Please help me to set the completed date in TASK.


#11

Hi MuzammilKhan,
Please check with this dates
Start Date = Fri Jul 01 09:30:00 IST 2011
Due Date = Fri Jul 01 09:30:00 IST 2011
Completed Date = Mon Apr 04 22:04:47 IST 2011


#12

@Rajmohammad

The setDateCompleted() method gets or sets the date when the user completed work on the task and throws
com.aspose.ms.System.ArgumentException when start date is less than date completed. You cannot set completed date before start date.

However, you may set completed percentage as given below if it works for you.
f_objMapiTask.setPercentComplete(100);

Moreover, please feel free to write back to us if you need additional information.


#13

Hi MuzammilKhan,
For setDateCompleted() method gets or sets the date when user completed work on the task. But in outlook if you check the completed date is set properly if start date is greater than completed date or future date. So If you have any possible way to set Completed Date please suggest in case of if start is greater than Completed date.


#14

@Rajmohammad

Thank you for your feedback. We have logged this issue with ID “EMAILJAVA-34483” for further investigation and you will automatically be informed here once we have more information to share.


#15

The issues you have found earlier (filed as EMAILJAVA-34483) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by muhammadahmad