We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Appointment.UpdateAppointment throws "the given key was not present in the dictionary"

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;
}





Hi Joe,


Thank you for contacting Aspose support team.

I have used your code to reproduce the scenario here, but am afraid that your code is working fine and no exception is raised. Could you please give it a try on some other system and let us know the feedback?

P.S. I tired it on a 32-bit system, Windows 7, VS 2013, .NET framework 4.0/4.5.

Thanks for the update Kashif. On further review of my code, the issue appears to be in the calling method. The from and to dates were being passed in as 1/1/1753, and other parameters were not set.

Hi Joe,

Could you please confirm to us if you were able to solve this issue or still facing problem? Your feedback will allow us to assist you further.

I am sorry I was not clear, the issue is not with Aspose.email, the issue was in my code.

This matter should be closed.

Thank you.

Hi Joe,


Thank you for providing the feedback. Please feel free to write to us in case you have any additional inquiry/query related to Aspose.Email. We’ll be glad to assist you further.