Steps
- Create Recipient List
- Create a Marketing Email Address
- Add emails to recipient list
- Assign a Recipient List for Email Marketing
When I slowly debug, I managed to pass all the steps with a successful message from sendgrid.
But in non-debug mode, although I added emails to the recipient list (the results are returned from sendgrid), when in step 4 I return the list without recipients . I am updating the browser and viewing the letters in the recipient list.
I tried to put timer.interval before starting to process step 4, but also getting the same results.
VB ProcessHandler Code
' Add email and name to recipient list
If oSendMarketingEmail.AddEmailToList(oItemDetails.Email, oItemDetails.Full_Name, sRecipientList) = False Then Exit Try
' Wait for the email and name added to recipient list
Dim timer As New Timers.Timer
timer.Interval = 20000
' Assigning recipient list to marketing email
If oSendMarketingEmail.AddListToMarketingEmail(sMarketingEmailName, sRecipientList) = False Then Exit Try
VB Function Code
Public Function AddEmailToList(sEmailAddress As String, sName As String, sRecipientList As String) As Boolean
Dim ResultsHTML As String = ""
Dim URL As String = (Convert.ToString("http://sendgrid.com/api/newsletter/lists/email/add.xml?list=") & sRecipientList) + "&data=" + "{""email"":""" + sEmailAddress + """,""name"":""" + sName + """}" + "&api_user=" + SendGridUserName + "&api_key=" + SendGridPassword
Dim SendGridResponse As String = PerformHTTPGet(URL)
ResultsHTML += (Convert.ToString("Adding email to List: ") & SendGridResponse) + "<br/>"
' Check respond status - success
If Not ResultsHTML.Contains("insert") Then logger.log.Info(ResultsHTML) : Return False Else Return True
End Function
Public Function AddListToMarketingEmail(sMarketingEmailName As String, sRecipientList As String) As Boolean
Dim ResultsHTML As String = ""
'Assign list to marketing email
Dim URL As String = (Convert.ToString((Convert.ToString("http:
Dim SendGridResponse As String = PerformHTTPGet(URL)
ResultsHTML += (Convert.ToString("Assigning Marketing Email to List: ") & SendGridResponse) + "<br/>"
' Check respond status - success
If Not ResultsHTML.Contains("success") Then logger.log.Info(ResultsHTML) : Return False
End Function