Can't send to Umbraco Member group (Specified cast is not valid)
Hi,
When I tries to send a newsletter to a Umbraco Member Group I receive an error in the "Send newsletter" modal dialog.
The sam happens with a scheduled send-out?
Does anyone have any suggestion for where to start looking for the reason for this?
// Kalle
Thi is written to the lg during a scheduled send-out:
At /umbraco/newsletterstudio/pages/NewsletterCheckForScheduledSendOut.aspx (Referred by: ): System.InvalidCastException: Specified cast is not valid. at NewsletterStudio.Bll.Providers.UmbracoSubscriptionProvider.GetSubscribersForSendOut(String listItemValue, SendOutParams parameters) at NewsletterStudio.Model.Newsletter.ValidForSending(List`1& errs) at NewsletterStudio.Pages.NewsletterCheckForScheduledSendOut.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
If this error shows when you are trying to send manually chances are big that it happens when performing a scheduled send out as well.
1. Are you using any custom providers or render tasks? 2. Have you tried with different member groups? 3. Are you using any custom properties on the members?
Are you using the "newsletter"-property? This value is checked for nulls and then converted to an int (umbraco uses ints for bools) and checked before adding this user to the send out list.
I think that this could be the problem, if the newsletter property contains something else than null or an int the cast will probably fail.
You where absolutely correct, it must have been the "newsletter" property.
A week ago I exported all these members and manually set this property to 1 and then imported them again.
But since then our users added 4 more members where this property wasn't set at all or set to an umbraco default value.
Strangely it doesn't seem like you handle the null values, cause once I set these 4 members to newsletter=1 the process ran on without any error messages for all of my 1184 members... ; )
The null values are handled but it could be the case that the value is String.Empty and that is not handled at the moment. Seams like a small bugg in the provider that we will have to fix in the next version.
If you really need this to be fixed asap I could share the code for the provider so that you can fix this errors and use it as a customer subscription provider. Send me an email on markus [at sign goes here] enkelmedia.se
If using the newsletter-property on a member the value has to be set to true (1) for it to be treated as valid. If you need to send to users that haven't had the option to choose - just set "true" as the default value for new members.
(But in Sweden your not allowed to send emails to private persons who have not explicity said yes to it)
Can't send to Umbraco Member group (Specified cast is not valid)
Hi,
When I tries to send a newsletter to a Umbraco Member Group I receive an error in the "Send newsletter" modal dialog.
The sam happens with a scheduled send-out?
Does anyone have any suggestion for where to start looking for the reason for this?
// Kalle
Thi is written to the lg during a scheduled send-out:
At /umbraco/newsletterstudio/pages/NewsletterCheckForScheduledSendOut.aspx (Referred by: ): System.InvalidCastException: Specified cast is not valid. at NewsletterStudio.Bll.Providers.UmbracoSubscriptionProvider.GetSubscribersForSendOut(String listItemValue, SendOutParams parameters) at NewsletterStudio.Model.Newsletter.ValidForSending(List`1& errs) at NewsletterStudio.Pages.NewsletterCheckForScheduledSendOut.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Hi Kalle!
If this error shows when you are trying to send manually chances are big that it happens when performing a scheduled send out as well.
1. Are you using any custom providers or render tasks?
2. Have you tried with different member groups?
3. Are you using any custom properties on the members?
Hi Markus and thanks for your reply!
Hi!
Are you using the "newsletter"-property? This value is checked for nulls and then converted to an int (umbraco uses ints for bools) and checked before adding this user to the send out list.
I think that this could be the problem, if the newsletter property contains something else than null or an int the cast will probably fail.
Hi Markus!
You where absolutely correct, it must have been the "newsletter" property.
A week ago I exported all these members and manually set this property to 1 and then imported them again.
But since then our users added 4 more members where this property wasn't set at all or set to an umbraco default value.
Strangely it doesn't seem like you handle the null values, cause once I set these 4 members to newsletter=1 the process ran on without any error messages for all of my 1184 members... ; )
// Kalle
Hi!
The null values are handled but it could be the case that the value is String.Empty and that is not handled at the moment. Seams like a small bugg in the provider that we will have to fix in the next version.
If you really need this to be fixed asap I could share the code for the provider so that you can fix this errors and use it as a customer subscription provider. Send me an email on markus [at sign goes here] enkelmedia.se
// markus
OK, I see...
Thanks for your suggestion Markus,
But I think that I'll try to handle the default values via the creation process instead since all these members are created programatically anyway...
// Kalle
BTW, are/will these null / String.Empty values being handled as subscribed or as unsubscribed?
From my - "opt-out" - point of view a null/empty value should be treated as "subscribed" when sending out newsletters.
That member haven't yet said yes or no so it makes sense to send an email with the option to unsubscribe...
// Kalle
Hi!
If using the newsletter-property on a member the value has to be set to true (1) for it to be treated as valid. If you need to send to users that haven't had the option to choose - just set "true" as the default value for new members.
(But in Sweden your not allowed to send emails to private persons who have not explicity said yes to it)
is working on a reply...