Hi Ashley,
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,
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?
{
Bias = -60,
StandardBias = 0,
DaylightBias = -60,
DaylightDate = daylightTransitionTime,
StandardDate = standardTransitionTime,
Year = 1601
};
Hi Ashley,
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,
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,
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