473,320 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Call a webpage recursively to send multiple emails

Hi

It's been a while since I asked a question and I've trolled many, many discussion groups and forums without success and I'm not sure that my problem has a solution but here goes.

I have a website which is hosted (successfully) on my own machine at home, it uses IIS7; classic ASP; activeX DLLs and an Access 2007 database. The website has an administration entrance where all the maintenance happens. I am transferring all the admin tasks from the Access DB to the Admin pages where most options are working OK.

The website sends eMail to members once or twice a week using CDOSYS in the DLL, currently the Access DB form displays the progress showing the detail of who is currently being mailed, how many are remaining and a visual progress bar and When all mails are sent the form closes.

I can reproduce the progress bar with CSS (although non moving at the moment) mail details etc and the code in the DLL to make it happen. The question is this:-

How can I call the ASP page recursively before or after each mail has been sent. The DLL code I have will either send one or all emails, and if I send say 200 mails this leaves the webpage blank for three or four minutes until the DLL function returns, up until that point, I do not know what is happening.

Any help would be appreciated.
Oct 4 '11 #1
17 3299
Frinavale
9,735 Expert Mod 8TB
It sounds like you should be using Ajax for this task.
Write a JavaScript array of email-strings into the page.
Use Ajax to loop through this array and submit the email to asp page that is responsible for emailing...only loop when the Ajax request returns the response to the page....at that point you can also update your progress bar to indicate how far through the email list you are.

-Frinny
Oct 4 '11 #2
@Frinavale
Thanks, however I've not used Ajax and it may take some time to learn. There may be another answer in the short term.

Regards
Oct 4 '11 #3
Frinavale
9,735 Expert Mod 8TB
I can't really see this solution working well without using Ajax or JavaScript.

How do you see it working without JavaScript?

I mean, after completing one email, you'd have to send a response to the browser...at which time the browser would have to send up another request to send the next email. How is the browser going to send that next request without a client script??

I don't think it will take as long as you think to learn how to do this with Ajax. It took me maybe a day to figure out....and there's a wonderful, friendly team of JavaScript experts here on bytes that would love to give you a hand :)

-Frinny
Oct 4 '11 #4
This is the reason I've asked the question because I don't know how to do this bit.

The eMails are actually personalised HTML invitations to our members which contain embedded graphics and a link holding user and visit information from the database which allows the invitee to enter the website and visit a dynamic page which contains information specific to that invitation. The DLL constructs and sends the eMail and not the webpage.

As I stated previously I can send as many eMails as necessary but I need something on the screen to tell me that stuff is still happening. I thought of one of those spinning stars, but have been unable to locate one anywhere, when the mail session ends the DLL reports back to the web page the number of mails sent.

Hope this sheds a little more light on the subject
Oct 5 '11 #5
Frinavale
9,735 Expert Mod 8TB
It is a lot easier if you don't want a progress bar and you just want to display a graphic or message telling the user that the server is processing their request!

You still need to use JavaScript for this but it's quite a bit more simple.

Just add an element on the page that which will contain your image or message and set it's style of "display:none" so that it is not showing at first. Then add an "onclick" to your button that will call a JavaScript method that displays the element (when the user clicks the button). When the request returns from the server the element will be re-hidden because that is it's natural state.

For example:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.   <head>
  3.     <script type="text/javascript">
  4.       function displayMessage()
  5.       {
  6.         document.getElementById("processingMessage").style.display="block";
  7.       }
  8.     </script>
  9.   </head>
  10.   <body>
  11.  
  12.     <div id="processingMessage" style="border:solid 1px black;  position:fixed; display:none;background-color:red;">
  13.       Processing your request.
  14.     </div>
  15.  
  16.     <button type="button" onclick="displayMessage()">Click Me</button>
  17.   </body>
  18. </html>
-Frinny
Oct 5 '11 #6
Thanks for this, however, I currently use a popup window with the message that eMail is being sent, when the server DLL has completed it returns the number of eMails sent, which is similar to your suggestion, the graphics are part of the HTML eMail not the webpage.

What I am trying to do is continuously show the state of each eMail being sent, not have a big time gap with no user advice.

Maybe I could have an array filled with the mail data and then send them individually to the DLL and wait the 1 second or so it takes to send and update the page that way.

Kind regards
Oct 6 '11 #7
Frinavale
9,735 Expert Mod 8TB
The thing is that you cannot have the "wait" happen in your server-side code. You have to have the "waiting" happen in your client side code...using JavaScript.

You can't have the waiting happen in your server-side code because the response will never be sent to the browser and the browser's UI won't be updated.

We're kind of returning to my original recommendation here...you don't need to use Ajax (Ajax just makes it smoother).
Oct 6 '11 #8
I have not said the wait will happen on the server; here is a snippet of my code.

Visit is the entry point to the ActiveX DLL and its major class
reportmail is a class in the DLL sendReportMail is a public Function in reportmail which executes the confiuration and sending of eMail also returning the variant howMany containing the number of eMails sent. True and False indicate if a test eMail is sent to the operator for testing purposes.

The ASP code below calls the function and waits for the return of howmany. If howmany contains anything it is currently sent to a page to view.

Expand|Select|Wrap|Line Numbers
  1. Dim howMany
  2.  
  3. If request("mailaction") = "sendmail" then
  4.   select case request("whichMail")
  5.     case 1
  6.       Visit.reportmail.sendReportMail True, howMany
  7.     case 2
  8.       Visit.reportmail.sendReportMail False, howMany, Request("clientid")
  9.     case 3
  10.       Visit.reportmail.sendReportMail False, howMany     
  11.   end Select
  12.  
  13.   if howMany <>"" then
  14.     Response.Buffer = True
  15.     Response.Clear
  16.     Response.Redirect "../admin/sniffer.asp?Sent=" & howMany
  17.   end If
  18. End if
So the wait happens on the client until the server returns its answer.

I am more and more thinking this is not achievable i.e to see my counter going 1 of 250 sent.... 73 of 250 sent etc.

I may look at other ways.

Kind regards
Oct 6 '11 #9
jimatqsi
1,271 Expert 1GB
Why not just send a few emails at a time? Arrange a loop to call the email process for one email or a small group of emails and show the progress before each call? I don't know much about web apps - maybe it shows :)

Jim
Oct 7 '11 #10
Frinavale
9,735 Expert Mod 8TB
I normally don't work with classic asp but here's an example of what I was talking about.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.   <title>test asp</title>
  4. </head>
  5. <body onload="startTimer()">
  6.   <form action="test.asp" method="post" id="testForm">
  7.  
  8.   <%
  9.     dim numLeft
  10.     numLeft=Request.Form("numLeft")
  11.     If numLeft<>"" Then
  12.  
  13.         numLeft = numLeft - 1
  14.  
  15.         dim percentComplete
  16.         percentComplete = (20-numLeft)/20*100
  17.  
  18.         Response.Write(percentComplete)
  19.         Response.Write("%")
  20.  
  21.         If numLeft<0 Then
  22.           numLeft=20
  23.         End If
  24.  
  25.     Else 
  26.       numLeft=20
  27.     End If
  28.   %>
  29.  
  30.     <input type="Hidden" name="numLeft" id="numLeft" value="<%=numLeft%>" />
  31.     <script type="text/javascript">
  32.       function submitPage()
  33.       { 
  34.         var numLeft = Number(document.getElementById("numLeft").value);
  35.  
  36.         if(numLeft>0)
  37.         {
  38.           document.getElementById("testForm").submit();
  39.         }       
  40.       }
  41.       function startTimer()
  42.       {
  43.          var t=setTimeout("submitPage()",1000);
  44.       }
  45.     </script>
  46.   </form>
  47. </body>
  48. </html>
Pretend the "numLeft" is actually the "number of emails left to send". This will change as the emails are sent...

-Frinny
Oct 7 '11 #11
@jimatqsi
Thanks Jim, however, when sending anything up to 600-700 mails I would spend all day clicking the go button. How would you 'arrange a loop' because basically that's what this is all about

Regards
Oct 7 '11 #12
@Frinavale
I could no get your script to run IE gave me a 'Object doesn't support this property or method

Kind regards
Oct 7 '11 #13
Frinavale
9,735 Expert Mod 8TB
Umm I just tested it in IE8 and I don't get any problems...
Refresh the page, click the "line numbers" to turn off the line numbers for the code that I posted...copy the code that I posted and paste it into a file called "test.asp"...
Oct 7 '11 #14
When I copied the first time a line of text was deleted. Does work now in IE9.

Can this be made to call my DLL function ?
Oct 7 '11 #15
Frinavale
9,735 Expert Mod 8TB
Do you see what I'm doing there?

I'm calling a JavaScript function every second which submits the page to the server if a counter (stored in a HiddenField) is greater than 0.

My server side code then subtracts one from a "counter" value, stores it in the HiddenField and returns to the browser....

Then the process starts over again.

There's no reason why you couldn't call your emailing functionality and store the number of emails still needing to be sent in the HiddenField...which the JavaScript method could check.

You could create a progress bar type thing using this concept.

It would be even smoother if you were to use Ajax ;) ;)

-Frinny
Oct 7 '11 #16
Hi Frinny

Its been good coversing with you, but, over the weekend I was sending 400 mails and less than halfway through, the server rejected one of the addresses. My MS Access system gave me the error message and I was able to track the offending address and resend the balance. This gave rise to me thinking of handling exceptions, errors and large arrays of mail data. I said at the outset of this thread that what I wanted to do may not be achievable, I am now thinking that that may be the case and I shall use the Access setup for eMailing and the website for everything else.

Once again thanks for your input.

John C Garvey
Oct 10 '11 #17
Frinavale
9,735 Expert Mod 8TB
John, I'm sorry that you were unable to solve your problem.

If you're emailing that much you should consider using an emailing list...If you're not using your own SMTP server, you're probably going to run into problems because your task will be considered as "spamming" and will likely be shut down.

-Frinny
Oct 11 '11 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: rdemyan | last post by:
My app creates a building report. My users have requested that I provide functionality to e-mail these "building reports" to building managers once a month. So assuming that I have the...
1
by: Jeremy | last post by:
I have a table with user names and their balance. I am going to say there are 1000 people that need to get an email of their balance statement. I have one query that pulls the names and the...
1
by: shubhrarustagi | last post by:
hi, I'm a beginner developer and one of my first tasks is to develop automatic emails application in .net. We need to send automatic emails to users whose credit cards are expiring, create email...
10
by: crazycooter | last post by:
I found an old thread on this (http://groups.google.com/group/alt.php/ browse_thread/thread/751edb9c723316c4/ea9bf92a9c6b807c?lnk=gst&q=mail() +duplicate&rnum=7#ea9bf92a9c6b807c), but there didnt...
0
by: =?Utf-8?B?am9lbA==?= | last post by:
When I posted a comment, I received a message that you had tried 3 times to send me emails but had been unable to do so. You asked me to solve this problem. How do I solve this problem? -- joel
1
by: prasath1984 | last post by:
hi, This is prasath i want the code to send bulk emails
2
by: techsri | last post by:
Hi, We are going to launch a website which offers free e-learning courses to the users. we are facing some problems to build my site. The problem is about, We want add push email feature to our...
2
by: palanisiva | last post by:
Hi, I am using PHP mailer to send out 2 different emails. The problem I am having is only the first email is ever sent out. Below is my code. The first email $to but i add two mail id mail not...
0
by: rserrador | last post by:
Hello. I'm creating a db in access 2007 and i want to have a buton on a report where i can send bcc multiple emails from a query. Can someone help me with the VBA code please.
11
by: londres9b | last post by:
I want to send multiple emails from php with one unique script. The emails are from a mysql database table. How can I achieve this?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.