One approach would be to add an if statement in your Sub SendMail
Sub SendMail(TheName, TheAddress)
If((TheName <> "") AND (TheAddress <> "")) Then
Dim objMessage, Rcpt
smtpServer = "mail.mydomain.com"
body = "Hello World"
Rcpt = Chr(34) & TheName & Chr(34) & "<" & TheAddress & ">"
set objMessage = Server.CreateObject("CDO.Message")
set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
cdoConfig.Fields ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
cdoConfig.Fields ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="test@mail.mydomain.com"
cdoConfig.Fields ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="123456"
cdoConfig.Fields.Update
set objMessage.Configuration = cdoConfig
objMessage.Subject = "This Month's Sales"
objMessage.From = """Acme Sales"" <test@mail.mydomain.com>"
objMessage.To = Rcpt
objMessage.HTMLBody = body
objMessage.Send
EndIf
End Sub
This way it will only process if the parameters TheName and TheAddress have a value.