Developer forum

Forum » Development » Issue with custom recipientprovider

Issue with custom recipientprovider

Anders Ebdrup
Reply

Hi Dynamicweb,

 

I have an issue with a custom recipient provider due to this check:

                LogEvent(_message, "Verifying Quarantine Period of {0} minutes.", _message.QuarantinePeriod)

                Dim now = DateTime.Now
                Dim quarantinePeriod = _message.QuarantinePeriod
                Dim keys = Recipient.GetRecipientKeysWithLatestSentTimeByMessageId(_message.Id)

                If keys.Count > 0 Then
                    For i = _recipients.Count - 1 To 0 Step -1
                        Dim r = _recipients(i)
                        Dim rKey = r.RecipientKey
                        Dim totalMinutesSinceLast = now.Subtract(keys(rKey)).TotalMinutes
                        If keys.ContainsKey(rKey) AndAlso totalMinutesSinceLast < quarantinePeriod Then
                            _recipients.RemoveAt(i)
                            LogEvent(_message, "Removed recipient '{0}' due to Quarantine Constraint. Last sent time (minutes ago): '{1}', Quarantine Period: '{2}'.", r.RecipientKey, totalMinutesSinceLast, _message.QuarantinePeriod)
                        End If
                    Next
                End If

 

Where you on this line: Dim totalMinutesSinceLast = now.Subtract(keys(rKey)).TotalMinutes assumes that the same recipients is available in the recipient list each time and causes this exception:

Message: The given key was not present in the dictionary.
StackTrace:    at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Dynamicweb.EmailMessaging.MessagingHandler.SaveRecipients() in E:\Program Files (x86)\Jenkins\jobs\Release DW87\workspace\Dynamicweb\EmailMessaging\MessagingHandler.vb:line 254
   at Dynamicweb.EmailMessaging.MessagingHandler.Process() in E:\Program Files (x86)\Jenkins\jobs\Release DW87\workspace\Dynamicweb\EmailMessaging\MessagingHandler.vb:line 104

 

As I see it you should add this:

                        If keys.ContainsKey(rKey) Then
                            Dim totalMinutesSinceLast = now.Subtract(keys(rKey)).TotalMinutes
                            If keys.ContainsKey(rKey) AndAlso totalMinutesSinceLast < quarantinePeriod Then
                                _recipients.RemoveAt(i)
                                LogEvent(_message, "Removed recipient '{0}' due to Quarantine Constraint. Last sent time (minutes ago): '{1}', Quarantine Period: '{2}'.", r.RecipientKey, totalMinutesSinceLast, _message.QuarantinePeriod)
                            End If
                        End If

 

 

Please make a hotfix this as soon as possible for this to work.

 

Best regards, Anders


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Anders,

I've created a bug report for this issue, so we can get it fixed. The bug number is 19842. Based on the stack trace build path, I've slated the fix for 8.7.1 and 8.7. Let me know if you need it in another branch as well.

- Jeppe

Votes for this answer: 1
 
Kristian Kirkholt
Reply

Hi Anders

The problem #19842 "EmailMessaging assumes a given recipient key is present"  has now been fixed in version 8.7.0.10

You are able to find this build in the download section:

http://developer.dynamicweb-cms.com/downloads/dynamicweb-8.aspx

Please contact Dynamicweb Support if you need any additional help regarding this.

Kind Regards
Dynamicweb Support
Kristian Kirkholt

 
Anders Ebdrup
Reply

Thank you for a very quick response and a hotfix! :-)

 

You must be logged in to post in the forum