Insert into a databse through an email using ajax

Hi all

I was wondering if anyone has ever tried or knows how i can update/insert a record directly from an email.

Break down.

I have got an email i want to send out with thre options on it,

Good
Okay
Bad.

All i want the receiver to do is to click on a link the will update my database with their click on it. Without taking them to a webpage.

So if i take the javascript for updating a record with refreashing the page, surely it should work, but it does not.

Can anyone tell me how to do this.

Thank you in advance
Baker

p.s. code below on what i am using
<script type="text/javascript">
<!--
function InsertItem(str,str1) {
//document.SampleForm.myText.value = document.SampleForm.myText.value.toUpperCase()
//Firstly go to collect data for transmitting to webpage
      var xmlhttp; 

if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) 
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("get","http://www.mydomain.co.uk/Replies/reply.aspx?P="+str+"&R="+str1,true); 
    xmlhttp.send();
}
-->
</script>
<a href="javascript:InsertItem('1','Good')">Good</a><br /><a href="javascript:InsertItem('1','Okay')">Okay</a><br /><a href="javascript:InsertItem('1','Bad')">Bad</a><br /><br /><br /><br /><div id="txtHint">Nothing Said</div><br />

Open in new window

LVL 1
BakersvilleAsked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:
I think the links are still the most reasonable way.
You can have three different links - each one  pointing to servlet with different value of parameters - good, OK, bad -
and the only thing this servlet will do is to update database.
I think servlet does not need to send any page back - optionally it can rather send, say, another email to notify user
that her response was accepted.

In outlook - you can attach voting buttons to email, and when user selects the choice it will
send the data to the senders outlook - you can probably attach some listener to the
senders outlook and somehow call the program to store this response in database or maybe
even hack into Exchange server, or in les automatic way then export
your responses to MSAccess, but those will be much more painful things
and only limited to outlook users.
0
 
CEHJCommented:
There  needs to be something parsing the email content - is there?
0
 
BakersvilleAuthor Commented:
I am sorry, you have lost me.  Newbe to this kind of thing
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
CEHJCommented:
What is reading the email?
0
 
BakersvilleAuthor Commented:
I was hoping for a asp.net page to listen for the action. If thats what you mean?


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        
        


        Dim conn As SqlConnection

        conn = New SqlConnection("Data Source=SERVER;Initial Catalog=DB;Persist Security Info=True;User ID=sa;Password=~S0l1hull")

        Dim sqlIns As String = "INSERT INTO dbo.FeedBackEmailTest (Person1, Reply1) VALUES (@Person1, @Reply1)"

        conn.Open()
        Try
            Dim cmdIns As New SqlCommand(sqlIns, conn)
            cmdIns.Parameters.Add("@Person1", SqlDbType.NVarChar).Value = Request.QueryString("P")
            cmdIns.Parameters.Add("@Reply1", SqlDbType.NVarChar).Value = Request.QueryString("R")
            cmdIns.ExecuteNonQuery()
            cmdIns.Dispose()
            cmdIns = Nothing
        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            conn.Close()
        End Try

Response.Write("Person : " & Request.QueryString("P") & "<BR>Said : " & Request.QueryString("R"))


    End Sub

Open in new window

0
 
daveamourCommented:
Can you send me one of the emails?
0
 
BakersvilleAuthor Commented:
OK, what is your email address?
0
 
daveamourCommented:
dave@dacservices.co.uk
0
 
CEHJCommented:
Oh i see: the link is in an email. Quite a lot of email clients won't permit javascript, so you're better off simply using ordinary links
0
 
BakersvilleAuthor Commented:
daveamour: email sent
0
 
BakersvilleAuthor Commented:
CEHJ:

How would you suggest i do it? Or even better can you show/give me examples?

Baker
0
 
daveamourCommented:
I think CEHJ is right - any concerns with just using a normal link?
0
 
BakersvilleAuthor Commented:
My boss does not it going of anywhere.

But if that is the only way then i will have to thnk of another solution
0
 
CEHJCommented:
You don't need script. Look at the source code of any mail that you've got that contains a link you can click
0
 
colr__Commented:
Standard email clients (including Outlook) will not allow Javascript in a message as stated above, so this is a non starter. There are a couple of options available:

1) Have the link point to a server resource that when hit, will update the database. This does mean that a web page will open though. You could have the web page close itself automatically when it is rendered, but it would still pop the browser up in front of the user

2) You could maybe have the links that use mailto: so when the user clicks on one of them, a new prepopulated email opens which the suer just has to send. Have this email sent to a mailbox that is monitored by some java code, that would look at the incoming mails and update the database accordingly. This is the only way i can think of that would avoid opening a browser.
0
 
BakersvilleAuthor Commented:
Thank you, can not be done
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.