Solved

Loop until email server is available

Posted on 2013-06-29
4
335 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now