Solved

Loop until email server is available

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Logparser is the smartest tool I have ever used in parsing IIS log files and there are many interesting things I wanted to share with everyone one of the  real-world  scenario from my current project. Let's get started with  scenario - How do w…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

18 Experts available now in Live!

Get 1:1 Help Now