Link to home
Start Free TrialLog in
Avatar of Bob Schneider
Bob SchneiderFlag for United States of America

asked on

SMS Messaging Reliability Issue

I have an sms system in my web site that allows my users to text each other.  It has similar issues to my email system (I am not intending to double-post...I know these ideas are related but I was thinking they would be different enough to justify separate posts).  There are more 500 errors than I would like to see.  Here is my code...any feedback would be much appreciated.

	Set cdoConfig = CreateObject("CDO.Configuration")
	With cdoConfig.Fields
		.Item(cdoSendUsingMethod) = cdoSendUsingPort
		.Item(cdoSMTPServer) = "xxx"
		.Item(cdoSMTPAuthenticate) = 1
		.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
		.Item(cdoSendUsername) = "xxx"
		.Item(cdoSendPassword) = "xxx"
		.Update
	End With
	
	Set cdoMessage = Server.CreateObject("CDO.Message")
	Set cdoMessage.Configuration = cdoConfig

	'first send to head coach
	If Not CStr(lCoachProvider) & "" = "" Then
		With cdoMessage
			.From = sMyNumber & GetSendURL(lMyProvider)
			.To = sCoachNumber & GetSendURL(lCoachProvider)
			.TextBody = sMsg
			.Send
		End With
	End If
	
	'now send to designated recipients
	For i = 0 To UBound(Recips, 2) - 1
		If Not CStr(Recips(1, i)) & "" = "" Then
			With cdoMessage
				.From = sMyNumber & GetSendURL(lMyProvider)
				.To = Recips(2, i) & GetSendURL(Recips(1, i))
				.TextBody = sMsg
				.Send
			End With
		End If
	Next
		
	Set cdoMessage = Nothing
End If
	 			
Private Sub GetRecip(lMyID, sMyRole, sMyLevel)
	'currently only being used for the participants gotten from the roster groups...could also be used to get staff, contacts and assts as we did on the 
	'txt_msg page we will see which approach works better
	bIsRecip = False
	lThisProvider = 0
	sThisNumber = vbNullString
	
	Set rs2 = Server.CreateObject("ADODB.Recordset")
	sql2 = "SELECT Provider, Number FROM MyWireless WHERE MyID = " & lMyID & " AND MyRole = 'Participant'"
	rs2.Open sql2, conn, 1, 2
	If rs2.RecordCount > 0 Then
		If Not rs2(0).Value & "" = "" Then
			If Not rs2(1).Value & "" = "" Then 
				lThisProvider = rs2(0).Value
				sThisNumber = rs2(1).Value
				bIsRecip = True
			End If
		End If
	End If
	rs2.Close
	Set rs2 = Nothing
End Sub

Private Function GetSendURL(lProviderID)
	If Not CStr(lProviderID) & "" = ""  Then
		Set rs = Server.CreateObject("ADODB.Recordset")
		sql = "SELECT SendURL FROM WrlsPrvdr WHERE WrlsPrvdrID = " & lProviderID
		rs.Open sql, conn, 1, 2
		If rs.RecordCount > 0 Then GetSendURL = rs(0).Value
		Set rs = Nothing
	End If
End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Schneider

ASKER

I get pretty accurate error reporting but it seems like I have cleaned up the code on those and I still get errors...mostly "no recipient found" issues.  Just wondering if there is something in my code that could be changed to:
1) better accommodate user errors, and
2) keep the thing from completely crashing in the middle of a send if a single error appears.