Solved

Loop until email server is available

Posted on 2013-06-29
4
336 Views
Last Modified: 2013-07-05
Is there a way to take this code and create a loop that will determine if the email server is available and send the email(s) only then, thus avoiding errors?  If so, please modify this code accordingly.

Here is my code:
					
%>
<!--#include file = "../../includes/cdo_connect.asp" -->
<%
	
			Set cdoMessage = CreateObject("CDO.Message")
			With cdoMessage
				Set .Configuration = cdoConfig
				.To = sPartEmail
				.From = Session("coach_email")
				.Subject = "Welcome to eTRaXC&reg; from Coach " & Session("coach_last")
				.TextBody = sMsg
				.Send
			End With
			Set cdoMessage = Nothing
			Set cdoConfig = Nothing

Open in new window


And here is my include file:
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
    .Item(cdoSendUsingMethod) = cdoSendUsingPort
    .Item(cdoSMTPServer) = "mail.bhi.com"
    .Item(cdoSMTPAuthenticate) = 1
    .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item(cdoSendUsername) = "xxx@blackhole.com"
    .Item(cdoSendPassword) = "xxx"
    .Update
End With

Open in new window

0
Comment
Question by:Bob Schneider
  • 2
4 Comments
 

Author Comment

by:Bob Schneider
ID: 39287298
BTW I have changed the mail.bhi.com to its ip address..still too soon to see if it helped or not.
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 250 total points
ID: 39287324
You cannot tell if the mail server is responding until you actually begin communicating with it, sending an HELO command.
As far as I know this is not possible with CDO or ASP directly, maybe one of the other (paid) email components can do this.
You certainly would not want a loop testing if the mail server is responding - what if it never responds? You would have an inifinite loop and mail servers can take quite some time to respond.
Your best option is wait for the response after trying to send an email and proceed from there.
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 250 total points
ID: 39287585
I agree, you don't want to keep looping.  What I would do is create a new table of the email transaction.  Each time you send the mail, capture the id of your email (thank you, confirmation, newsletter 1, newsletter 2 etc), the email address or contact id, time stamp and disposition.  The disposition will either be good or error.  Then every 30 or 60 minutes, run a script to hit all the "errors".   If the next try is good, update the disposition.  

This sample shows how to use an error code for mail.  

Where they have
If Err Then
        EMail = "ERROR " & Err.Number & ": " & Err.Description
        Err.Clear
    Else
        EMail = "Message sent ok"
    End If

Open in new window

change to
If Err Then
        EMail = "ERROR " & Err.Number & ": " & Err.Description
     ' ******  place your code to update the RS with the error disposition here
        Err.Clear
    Else
        EMail = "Message sent ok"
        ' ******  place your code to update the RS with the good disposition here

    End If

Open in new window


I have never used this type of error checking for cdo.  I have had similar issues to what you had, but once I updated my cdo code, all was good.
0
 

Author Closing Comment

by:Bob Schneider
ID: 39302373
Thanks as always!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question