Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Loop until email server is available

Posted on 2013-06-29
4
Medium Priority
?
349 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 1000 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 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Screencast - Getting to Know the Pipeline
Suggested Courses

824 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