473,395 Members | 1,969 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,395 software developers and data experts.

How can I update webpage data (javascript variable) by email post

I have a javascript running on a page hosted by googlepages at:
http://tgmcnaughton.googlepages.com/map2.htm
It uses the google map api to draw a map and plot a marker at a particular latitude and longitude.

I have a GPS device which sends emails to my gmail account which contain new latitude and longitude coords. I want to periodically check for new messages from the sender (or ideally respond to a "You've got mail message") and update the two variables in the javascript:

What language would be used for this kind of thing? It seems to me that it is in the same class of problem as emailing direct to a blog.

Of course the sender's name is fixed eg: xxx@airmessage.net and the dataformat is fixed. I just need to know how to get programmatic access to the email message.

Does this constitute server-side scripting? If JavaScript cannot do this, then what language would I use?
Thanks very much,
Aug 11 '07 #1
6 4674
jhardman
3,406 Expert 2GB
so if I understand you right, you have a form of some kind which a user will fill out and hit a submit button. The submit sends an email which alerts you of potential changes to some data. You would like to review the data in your email and then click some kind of "accept changes" button? If the data is fairly simple, it might be best to have a link in the email body with extensive querystring data:[html]<a href="mySite.com/updater.asp?long=12deg45min17sec&lat=75deg16min43s ec&update=true">Click here to update</a>[/html] then the actual changes will have to be handled on the updater.asp page. Does this help?

Jared
Aug 13 '07 #2
so if I understand you right, you have a form of some kind which a user will fill out and hit a submit button.
Jared
...
not quite... Let me try to explain a bit better:

The application is a simple GPS tracker. The elements are a device that combines a GPS chipset and a 2-way programmable alphanumeric pager. The pager can send a string in which its current latitude and longitude coordinates are encoded. I have it set to automatically send pages every 5 minutes whenever it is moving. The pages are automatically processed by the pager network service, converted and sent on as emails. I then get an email in my gmail account with a body containing a string like:

A3402.40611712.29122514400

which means:
Lat:34deg 02.40min
Long: -117deg 12.291min
time stamp: 22:51:44

So that's the source of the data. There are no forms or submit buttons or really any user input at all on this side.

At the webpage, there is a Javascript page with the following code:
http://tgmcnaughton.googlepages.com/map2.htm

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.   <head>
  5.     <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  6.     <title>Google Maps JavaScript API - tgm version 1.0</title>
  7.     <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=abcdefg"
  8.             type="text/javascript"></script>
  9.     <script type="text/javascript">
  10.     //<![CDATA[
  11.  
  12.     var lat = 34.232487;
  13.     var lon = -117.247165;    
  14.     var point = new GLatLng(lat,lon);
  15.  
  16.     function load() {
  17.       if (GBrowserIsCompatible()) {
  18.         var map = new GMap2(document.getElementById("map"));
  19.             map.setCenter(new GLatLng(lat,lon), 13);
  20.         map.addControl(new GSmallMapControl());
  21.         map.addControl(new GMapTypeControl());     
  22.         map.addOverlay(new GMarker(point));
  23.       }
  24.     }
  25.  
  26.     //]]>
  27.     </script>
  28.   </head>
  29.  
  30.   <body onload="load()" onunload="GUnload()">
  31.     <div id="map" style="width: 800px; height: 500px"></div>
  32.   </body>
  33. </html>
  34.  
I want to replace line 12 and 13 with code that will do the following:

login to my gmail account
find the latest email message
open the message
copy the bodytext into a string variable.
parse the string into lat and lon and time
update the two variables lat and lon with the current position of the pager.

Remember, the gmail account is just continuously receiving updates with new location strings. When the page is accessed, I want it to automatically go out and get an updated location.

Does this make sense?

Thanks,
Tim
Aug 14 '07 #3
jhardman
3,406 Expert 2GB
Tim,

yes, that makes sense, but it's a bit beyond me. Let me ask a hypothetical question: Is there any chance you could change the email address to which the mail is sent or if not, can they be forwarded to another address? If these went to a non-encrypted email address it would probably be easier. ASP can be used to open email, but I think it really only works well if the mail file is already on that server. I've never had a system set up that way, so I've never been in a position to test it. Then updating those variables are really easy. If you are interested in checking into it, I'm willing to help.

Jared
Aug 14 '07 #4
Tim,
Is there any chance you could change the email address to which the mail is sent
Jared
Yes, I can set the email address to whatever. I was sending to my gmail account (the webpage is hosted at googlepages).

It seems to me that what is needed is the same sort of method that is used to allow someone to email directly into their own blog. I have set up a blog at blogger.com and have been having the device send its email there. The site allows you to specify a "Mail-to-Blogger Address."
Any emails sent there are added as posts on the blog.
You can see the result at: tgmtrack.blogspot.com.
I like your idea of keeping everything on one server. I'm very glad to have your help with this. I have never used ASP before.
Thanks,
Tim
Aug 15 '07 #5
I got to thinking, maybe it's easier to email the coordinates into my publicly accessible blog at http://tgmtrack.blogspot.com/ (like I'm doing now) and then have the javascript at http://tgmcnaughton.googlepages.com/map2.htm
go out and extract the data from the blog. This might avoid the security issues inherent in logging into a remote email account.

I found a relevant tutorial at: http://classicasp.aspfaq.com/general...-web-page.html. It includes the following snippet.
Expand|Select|Wrap|Line Numbers
  1. <script language=javascript runat=server> 
  2.     var url = "http://www.espn.com/main.html"; 
  3.     var xmlhttp = new ActiveXObject("MSXML2.ServerXMLHTTP"); 
  4.     xmlhttp.open("GET", url, 0); 
  5.     xmlhttp.send(""); 
  6.     Response.Write(xmlhttp.responseText); 
  7.     var xmlhttp = null; 
  8. </script>
  9.  
I tried it but it doesn't work on my page at google pages. Maybe googlepages doesn't support ActiveXObjects?
Aug 15 '07 #6
jhardman
3,406 Expert 2GB
I got to thinking, maybe it's easier to email the coordinates into my publicly accessible blog at http://tgmtrack.blogspot.com/ (like I'm doing now) and then have the javascript at http://tgmcnaughton.googlepages.com/map2.htm
go out and extract the data from the blog. This might avoid the security issues inherent in logging into a remote email account.
that sounds like a good idea to me
I found a relevant tutorial at: http://classicasp.aspfaq.com/general...-web-page.html. It includes the following snippet.
Expand|Select|Wrap|Line Numbers
  1. <script language=javascript runat=server> 
  2.     var url = "http://www.espn.com/main.html"; 
  3.     var xmlhttp = new ActiveXObject("MSXML2.ServerXMLHTTP"); 
  4.     xmlhttp.open("GET", url, 0); 
  5.     xmlhttp.send(""); 
  6.     Response.Write(xmlhttp.responseText); 
  7.     var xmlhttp = null; 
  8. </script>
  9.  
I tried it but it doesn't work on my page at google pages. Maybe googlepages doesn't support ActiveXObjects?
I didn't realize googlepages supported asp at all. aren't they running with apache servers? Anyway, I was going to say the syntax looked a little off, but then I saw that you were writing in javascript rather than VBscript so that explains why It looks funky to me. The code in vbscript looks like this:
Expand|Select|Wrap|Line Numbers
  1. <%
  2. set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
  3. objHTTP.Open "GET", "http://www.mysite.com", false
  4. objHTTP.Send
  5. Response.Write objHTTP.ResponseText
  6. %>
  7.  
this sure looks equivalent to me as far as I can tell, so there is probably no problem with your code. IIS included activeX objects from the start because asp is severely limited without them, but I couldn't tell you whether google's servers implement them.

When you say "it doesn't work" what do you mean? does it give a specific error or freeze up or execute without that line or what?

Jared
Aug 15 '07 #7

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

Similar topics

3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
12
by: David Walker | last post by:
Hi I have a program which I need to interface with a webpage - the webpage will accept an input (probably a 'post' string from the program) and then will process it and needs to return a value. ...
6
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using enctype='multipart/form-data'? I'd also like it to...
1
by: Alex | last post by:
Hi, Everyday, I download data from a webpage and manually input data into my MS Access database. I am thinking of automate the routine by a VB script. The webpage I am visiting will return a...
3
by: laryten | last post by:
Hi, Is there a way to update the same web page instead of getting a new page each time we click the submit button? The simplest thing to do is to delete the current page (or go back to the...
1
by: roger.rigsby | last post by:
Ok I know how to get the data I want from mysql but I need to actually do something with this data and then send it back to mySQL. Company heads love the spreadsheet view so this is serious...
1
by: Chris | last post by:
I have a snippet of a function below I fire up in the body tag of my webpage to show a hidden layer and do some stuff when any link with the name "showlink" is clicked. In the displayed layer...
5
by: handoyo | last post by:
Hi all,i'm trying to show updated data in existing html td.. For example i got column that show last modified datetime,then i want to update data again,the column will changed to current time without...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.