danesparza / MailChimp.NET

:envelope: .NET Wrapper for the MailChimp v2.0 API
MIT License
179 stars 119 forks source link

How does one loop your expcetions #207

Open davidbuckleyni opened 7 years ago

davidbuckleyni commented 7 years ago

I have tried to loop your exceptions with no luck Catch ex As MailChimp.Errors.MailChimpAPIException

How does one return the string to be able to display to user also at min I am getting user subscribed to many times error.

I have used the same address a number of times but deleted them from the list should I still be getting above error if removed from list ?

 Try

            If System.Text.RegularExpressions.Regex.IsMatch(txtEmail.Text, "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*") = False Then

                lblblerror.Text = "Please enter a valid email address."

            Else

                Dim mailChimp As New MailChimpManager("-us5")
                Dim email As New EmailParameter
                email.Email = txtEmail.Text.Trim()
                mailChimp.Subscribe("", email, doubleOptIn:=False)
                lblVoucher.Text = "Voucher Code is : "
                lblVoucher.Visible = True
                btnNewGetVoucher.Visible = False
                btnDontShow.Visible = False
                'lets create the cookie that will control the page display of popup
                txtEmail.Visible = False

                Session("promotionGiftCode") = ""
                Dim cookie As System.Web.HttpCookie = New HttpCookie("galgormgrouppopup")
                cookie.Value = txtEmail.Text.Trim()
                Session("mailChimpEmail") = txtEmail.Text.ToString()
                cookie.Expires = DateTime.Now.AddDays(7)
                Response.Cookies.Add(cookie)

            End If
        Catch ex As MailChimp.Errors.MailChimpAPIException

            lblblerror.Text = ex.MailChimpAPIError.Error

        End Try