[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

CDO Mail and Setting a time delay

Posted on 2006-05-04
11
Medium Priority
?
406 Views
Last Modified: 2010-04-17
Hello -

I am sending an email using CDO mail.  The email is triggered by an action in my web app.  I would like send out a follow up email 5 minutes after the first (triggered email).  What is the best way to do that using either ASP or CDO ...?  Any recommendations?  

Thank you!

Suan
0
Comment
Question by:suzywal
  • 6
  • 5
11 Comments
 
LVL 9

Expert Comment

by:blandyuk
ID: 16610884
To be honest, you really need a service running on the server to check for this. If it's not your server, you can run an external ASP script on a schedule every 5 - 10 mins but you'll need a machine on all the time for that.

If you programming in ASP, and you have access to the server, you could write a VB6, VB.NET app to do this.
0
 

Author Comment

by:suzywal
ID: 16610900
I do have access to the server.  But I am wondering, how you schedule it to look for the particular record that caused the first email to be sent?  I am not a VB person...

0
 
LVL 9

Expert Comment

by:blandyuk
ID: 16611020
I presume you are storing the details of when an email is sent on a database, obviously storing the Date / Time? This enables you to have a service running which checks the database for follow-ups after 5 mins and execute them. Example:

(Based on an SQL database)

Table name: tblFollowups

Fields:
FollowupID [int] [PrimaryKey] [incremental]
UserID [int]
DateStamp [smalldatetime] ( Default = getdate() )
FollowedUp [bit] (Basically, Yes or No/ Default it No!)

This can be done on the user table as well but it usually better practice to separate it from a database structure point of view.

A SELECT statement could be: SELECT * FROM tblFollowups WHERE (DateDiff(n, DateStamp, getdate()) > 5) AND (FollowUp = 0)

This would list all the followups from which you can email them. Then you could set the "FollowUp" flag to "True" so they don't get included again.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:suzywal
ID: 16611049
Ah! OK.  Acutally, I just added all the fields to track the emails.

So would it be best to just put the run the ASP Page as a scheduled task on the machine once every 5 mintues (and loop through the records) ... or is that not the most efficient way to do it?
0
 

Author Comment

by:suzywal
ID: 16611056
That wasn't really clear....let me rewrite that!
/
////////////////////////////////


So would it be best to run the ASP Page as a scheduled task from the server machine once every 5 mintues (and loop through the records) ... or is that not the most efficient way to do it?
 
0
 
LVL 9

Expert Comment

by:blandyuk
ID: 16611096
It's up to you, you can do this way but with regards to error checking, it's not the best way. To be honest, it should'nt be a problem and it would be simplier if you do it this way as if it messes up, your last SQL query:

UPDATE tblFollowups SET FollowUp = 1 WHERE FollowupID IN(" & ProcessedIDs & ")
' ### ProcessedIDs will be the IDs delimited by comma: 1, 2, 6, 9 etc.

Wont execute so you can send again :)

----------

I've done the SQL query as the above because the below query:

UPDATE tblFollowups SET Followup = 1 WHERE (DateDiff(n, DateStamp, getdate()) > 5)

could remove records that haven't been sent if the script runs over 1 min as smalldatetime in SQL is to the near'est min, although, its unlikely. It's more accurate referencing the IDs anyway.
0
 
LVL 9

Accepted Solution

by:
blandyuk earned 1400 total points
ID: 16611124
On another note, your mail script that send emails using the CDO object, have you added a error catch script to catch emails that might fail to connect to the mail server? We thought of this at work and now store any failed emails to a database so we can re-send them. You would be amazed at the amount of failed emails we have per week!! unique ID is in excess of 3000 + in 1 yr!! Definatly worth thinking about and it's very simple to implement obviously storing the error description as it's mosting user error with regards to email being invalid. e.g.

user@hotmail.com.uk
user@yahoo.com.uk

WTF?? muppet! LOL :)
0
 

Author Comment

by:suzywal
ID: 16611146
I haven't put an error script in there yet  ...not smart, I know.

Thank you for your help!! I will write all that code tomorrow!

Susan
0
 
LVL 9

Expert Comment

by:blandyuk
ID: 16611153
No problem :) Any probs let us know.
0
 

Author Comment

by:suzywal
ID: 16611197
This may be a dumb question ... The only way I know how to trigger the code is using a scheduled task and ASP page ... is that a good way to go .. or is there a better way to execute the SQL.
0
 
LVL 9

Expert Comment

by:blandyuk
ID: 16611253
We use scripts just like that a work. It works a treat. Out bigger, more major scripts which take hours to run I've written in VB6 as I can catch errors more easily and it's not good practice running an ASP page for hours on end as you can imagine :)

Simple, quick scripts I find to be no problem. You can setup an email component in SQL and get an SQL package to send the emails out but it takes some setting up that. Probably not your preferred option.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

825 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