Steps
When I debug slowly, i managed to passed all steps with success message from sendgrid.
But in non debug mode, although i added emails to recipient list success(results return from sendgrid), when in step 4, i get results return List without recipients. I refresh the browser and saw the emails in the recipient list as well.
I tried to put timer.interval before start to process step 4 but also get the same results return.
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://sendgrid.com/api/newsletter/recipients/add.xml?name=") & sMarketingEmailName) + "&list=") & sRecipientList) + "&api_user=" + SendGridUserName + "&api_key=" + SendGridPassword
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
In SendGrid, the list-count can take a little while to update. One way to "force" it is to query the full list, which triggers the system to count through, and will update the count, which will then allow you to attach it properly.