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,


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

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=="")
if (window.XMLHttpRequest) 
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp.readyState==4 && xmlhttp.status==200)
<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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There  needs to be something parsing the email content - is there?
BakersvilleAuthor Commented:
I am sorry, you have lost me.  Newbe to this kind of thing
What is reading the email?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

BakersvilleAuthor Commented:
I was hoping for a 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)"

            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 = Nothing
        Catch ex As Exception
        End Try

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

    End Sub

Open in new window

Can you send me one of the emails?
BakersvilleAuthor Commented:
OK, what is your email address?
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
BakersvilleAuthor Commented:
daveamour: email sent
BakersvilleAuthor Commented:

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

I think CEHJ is right - any concerns with just using a normal link?
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
You don't need script. Look at the source code of any mail that you've got that contains a link you can click
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.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BakersvilleAuthor Commented:
Thank you, can not be done
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.