I've been trying to find a way to add an event to an Outlook calendar using data in a database table.
To that end, I've been trying to implement this solution
which looks like it covers what I need, but I've gotten stuck at a point before I can test it properly.
So far I've created a class called iCalEmail, registered the build as an assembly with SQL Server, and created a procedure to call that assembly.
Unfortunately it was all going a little too well - my build returns the following error when I run the procedure:
System.ArgumentException: Item has already been added. Key in dictionary: 'method' Key being added: 'method'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Specialized.StringDictionary.Add(String key, String value)
at System.Net.TrackingStringDictionary.Add(String key, String value)
at iCalEmail.StoredProcedures.SendiCal(DateTime startDateTime, DateTime endDateTime, String emailSubject, String userName, String userEmailAddress, String cnAttendee, String methodType, DateTime createdOn, String notes, String UID, String location, String seqNo, String smtpserver, Int32 smtpport)
I searched around online and saw that a lot of people seem to be suggesting that I'm either using a collection which has duplicate keys, or that I have two environment variables with the same name. I could be missing something, but so far as I can tell neither of these solutions apply.
Can anyone discern what could be causing the exception?
Class and Procedure to follow:
CREATE ASSEMBLY [iCalEmail]
WITH PERMISSION_SET = UNSAFE
create procedure dbo.usp_mb_eventnotify(@startDateTime datetime
, @endDateTime datetime
, @emailSubject nvarchar(255)
, @userName nvarchar(255)
, @userEmailAddress nvarchar(255)
, @cnAttendee nvarchar(255)
, @methodType nvarchar(255)
, @createdOn datetime
, @notes nvarchar(255)
, @UID nvarchar(255)
, @location nvarchar(255)
, @seqNo nvarchar(255)
, @smtpserver nvarchar(255)
, @smtpport int)
as external name iCalEmail.[iCalEmail.StoredProcedures].SendiCal;
exec CreateEvent '2013-05-14 11:00:00'
, 'Test Appointment'
, 'Paul Atherton'
, 'This is a test appointment'
, 'Testing Location - The test base'