Solved

Loop until email server is available

Posted on 2013-06-29
4
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 53

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

624 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