We are using Aspose.Email version 4.4.0.0. We have code to add an appointment and it is throwing this error:
The given key was not present in the dictionary.
at ?.?.?(?? , DateTime )
at Aspose.Email.Mail.Appointment.?e(? , DateTime )
at Aspose.Email.Mail.Appointment.?e( , Int32 )
at Aspose.Email.Mail.Appointment.UpdateAppointment(Int32 sequenceId)
at clsEmailUtil.AddAppointment(MailMessage msg, DateTime Start, DateTime End, String location, String Summary, String Description, String EmailSubject) in c:\inetpub\wwwroot\PbkNHCarroll\App_Code\clsEmailUtil.cs:line 1090
at clsEmailUtil.SendAppointment(DateTime Start, DateTime End, String Location, String Summary, String Description, String To, Boolean System, String EmailSubject) in c:\inetpub\wwwroot\PbkNHCarroll\App_Code\clsEmailUtil.cs:line 602
at Core_AddAppointment.btnAddAppointmen_ServerClick(Object sender, EventArgs e) in c:\inetpub\wwwroot\PbkNHCarroll\Core\AddAppointment.aspx.cs:line 231
The code pasted below worked correctly in a previous version of Aspose.Email (2.3.0.0).
public static MailMessage AddAppointment(MailMessage msg, DateTime Start, DateTime End, string location, string Summary, string Description, string EmailSubject)
{
Appointment app = new Appointment(location, Start, End, msg.From, msg.To);
app.Summary = EmailSubject;
app.Description = Description;
string timeZoneTZValue = GetTimeZone();
if (!String.IsNullOrWhiteSpace(timeZoneTZValue))
app.SetTimeZone(GetTimeZone());
app.UpdateAppointment(); – This is line 1090 of clsEmailUtil.cs
msg.AddAlternateView(app.RequestApointment());
return msg;
}
I thought the issue might be setting the time zone, but commenting those lines above still threw the error. GetTimeZone() pasted below. The value being returned in this case is "America/New_York"
private static string GetTimeZone()
{
string timeZone = “”;
string timeZoneDifference = AppConfig.TimeZoneDifference.ToString();
switch (timeZoneDifference)
{
case “1”:
timeZone = “America/New_York”;
break;
//case “0”:
// timeZone = “America/Chicago”;
// break;
case “-1”:
timeZone = “America/Denver”;
break;
case “-2”:
timeZone = “America/Los_Angeles”;
break;
case “-4”:
timeZone = “America/Anchorage”;
break;
default:
timeZone = “”;
break;
}
return timeZone;
}