TimeZone MapiCalendar

In a VCalendar event I can see the following
DTSTART;TZID="GMT Standard Time"

I assume I would use the following StartDateTimeZone in MapiCalendar ?
I've looked at the following post :
https://forum.aspose.com/t/25653

And the MapiCalendarTimeZone() does not have any parameters. I've just updated to the latest version.

Thanks



Hi Ashley,


Thank you for contacting Aspose support team.

Currently there is no such feature available which can be used to create MapiCalendarTimezone by using a standard string argument.

You may please consider following code to achieve this functionality and let us know the feedback.


public static void CreateAppointmentWithTimeZone()

{

// Declare the pst file

string pstFileName = @“C:\AsposeTests\calendar.pst”;

if (File.Exists(pstFileName))

File.Delete(pstFileName);


// Create the appointment

MapiCalendar appointment = new MapiCalendar(

“This is location of meeting”,

“Appointment”,

“This is a sample meeting body content”,

new DateTime(2015, 7, 12, 13, 0, 0),

new DateTime(2015, 7, 12, 14, 30, 0));


// Create the timezone (Romance Standard Time - Europe/Paris)

MapiCalendarTimeZoneRule daylightTransitionTime = new MapiCalendarTimeZoneRule

{

Hour = 2,

Milliseconds = 0,

Minute = 0,

Month = 3,

Seconds = 0,

Year = 0,

DayOfWeek = DayOfWeek.Sunday,

DayPosition = DayPosition.Last

};

MapiCalendarTimeZoneRule standardTransitionTime = new MapiCalendarTimeZoneRule

{

Hour = 3,

Milliseconds = 0,

Minute = 0,

Month = 10,

Seconds = 0,

Year = 0,

DayOfWeek = DayOfWeek.Sunday,

DayPosition = DayPosition.Last

};

MapiCalendarTimeZoneInfo mapiCalendarTimeZoneInfo = new MapiCalendarTimeZoneInfo

{

Bias = -60,

StandardBias = 0,

DaylightBias = -60,

DaylightDate = daylightTransitionTime,

StandardDate = standardTransitionTime,

Year = 1601

};

MapiCalendarTimeZone mapiCalendarTimeZone = new MapiCalendarTimeZone

{

KeyName = “Romance Standard Time”,

TimeZoneRules = new MapiCalendarTimeZoneInfoCollection { mapiCalendarTimeZoneInfo }

};


// Set the timezones in the appointment

appointment.StartDateTimeZone = mapiCalendarTimeZone;

appointment.EndDateTimeZone = mapiCalendarTimeZone;


// Create the pst and add the appointment to folder “Calendar”

PersonalStorage pst = PersonalStorage.Create(pstFileName, FileFormatVersion.Unicode);

FolderInfo calendarFolder = pst.CreatePredefinedFolder(“Calendar”, StandardIpmFolder.Appointments);

calendarFolder.AddMapiMessageItem(appointment);


// Read back the appointment from the pst

FolderInfo calendar = pst.GetPredefinedFolder(StandardIpmFolder.Appointments);

MessageInfoCollection messages = calendar.GetContents();


// Get the mapi calendar objects

MapiMessage[] mapiMessages = messages.Select(msg => pst.ExtractMessage(msg.EntryId)).ToArray();

MapiCalendar[] mapiCalendars = mapiMessages.Select(mapiMessage =>

(MapiCalendar)mapiMessage.ToMapiMessageItem()).ToArray();

}

Thanks, could you tell me a little more about Day Position? When I use TimeZoneInfo .GetAdjustmentRules(). I can’t see anything to relate to the Day Position

Hi Ashley,


DayPosition is linked with DayOfWeek e.g. if we say that a monthly recurrence has DayOfWeek.Saturday and DayPosition.Second, it means that it occurs on every second Saturday of the month. If it is DayPosition.Last, it means every last Saturday of the month.

I am afraid that I could not understand the usage of TimeZoneInfo.GetAdjustmentRulses() here. Could you please provide more details and sample code for observing the issue here? It will help us to understand the problem and provide assistance accordingly.

Sorry in the late reply, I was moved on to another piece of work. This is how I was using GetAdjustmentRules, would this be the correct way?


string name = “Romance Standard Time”;
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(name);
TimeZoneInfo.AdjustmentRule[] test = timeZoneInfo.GetAdjustmentRules();
MapiCalendarTimeZoneRule daylightTransitionTimeStart = new MapiCalendarTimeZoneRule {
Hour = Convert.ToUInt16(test[0].DaylightTransitionStart.TimeOfDay.Hour),
Milliseconds = Convert.ToUInt16(test[0].DaylightTransitionStart.TimeOfDay.Millisecond),
Minute = Convert.ToUInt16(test[0].DaylightTransitionStart.TimeOfDay.Minute),
Month = Convert.ToUInt16(test[0].DaylightTransitionStart.TimeOfDay.Month),
Seconds = Convert.ToUInt16(test[0].DaylightTransitionStart.TimeOfDay.Second),
Year = Convert.ToUInt16(test[0].DaylightTransitionStart.TimeOfDay.Year),
DayOfWeek = test[0].DaylightTransitionStart.TimeOfDay.DayOfWeek,
// DayPosition = DayPosition.Last
};

Also for the below:
MapiCalendarTimeZoneInfo mapiCalendarTimeZoneInfo = new MapiCalendarTimeZoneInfo

{


Bias = -60,


StandardBias = 0,


DaylightBias = -60,


DaylightDate = daylightTransitionTime,


StandardDate = standardTransitionTime,


Year = 1601


};

How did you get 1601 as the year?

Is it all possible to create an appointment just from the following:
“DTSTART;TZID=Europe/London:20150912T140000\r\nDTEND;TZID=Europe/London:20150912T143000\r\nRRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=2SA”

Hi Ashley,


Thank you for contacting Aspose support team again.

The day position property is not available in GetAdjustmentRules function as described here. However, in Aspose.Email, it is an additional property to define exactly the start/end of MapiCalendarTimeZone. You may please set this property using DayPosition enumerator. Rest it seems to be a proper way to initialize the MapiCalendarTimeZoneRule using values from the AdjustmentRule array retrieved using GetAdjustmentRules.

Year 1601 is set as it is the minimum year of DataTime class as mentioned here.

I am afraid that there is no direct method available to create appointment from the string you have provided. However, it can be used to create OccurrenceCount as shown in the previous code sample provided in this thread.

Please feel free to write us back if you have any other query in this regard.


Thanks for the reply, is there any logic for the date to be set at 1601, is it 1601 all the time?

Also, going back to your original example, once the appointment has been created. Should it not be displayed in the Outlook like so:
http://images.devs-on.net/Image/eknNKw23g286xktO-Region.png

If not, how do I go about doing this?

Thanks

Hi Ashley,


I have checked that this year 1601 is not necessary and you may provide any year like 2015. Regarding the output of the sample code here, it is observed that the output corresponds to the code and no abnormality is identified. Could you please explain the issue in the output of this code? We shall analyze it and provide assistance accordingly.

Thanks for the confirmation regarding the year.

Regarding the original code sample, it appears it does not work as I would expect. Below is a screen shot of the appointment created. The only thing I have changed is the date ie 09/09/2015.

  • [Appointment Created using code sample ](http://images.devs-on.net/Image/i8kK3F2mcI9LBFgt-Region.png)
  • [Appointment edited to reflect expected output.(area highlighted in yellow) ](http://images.devs-on.net/Image/rJp7uADCn557bxmg-Region.png)

I guess I am expecting to see the timezone on the appointment as the timezone is set to Paris. Hopefully this explains it better.

Hi Ashley,


Thank you for providing more detail and I have also observed this issue during testing. It is already logged under Id: EMAILNET-34866 and under discussion by the product team. I shall write here as soon as some update is received in this regard.

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