bizjosh
asked on
Adding a Script to Hyperlink
How do i add the below code into a hyperlink, so that i can
pass my email address and info into the hyperlink and when the user
clicks on the hyperlink, outlook will add the contact details
-
addOutlookContact.js:
var olContactItem = 2;
function contact( FirstName, LastName, bizPhone, Email, Company, JobTitle )
{
this.FirstName = FirstName;
this.LastName = LastName;
this.bizPhone = bizPhone;
this.Email = Email;
this.Company = Company;
this.JobTitle = JobTitle;
}
function saveContact( obj )
{
/* Create the Outlook Object and Contact Item */
out = new ActiveXObject( "Outlook.Application" );
contact = out.CreateItem( olContactItem );
/* Transfer the data */
contact.FirstName = obj.FirstName;
contact.LastName = obj.LastName;
contact.BusinessTelephoneN umber = obj.bizPhone;
contact.Email1Address = obj.Email;
contact.CompanyName = obj.Company;
contact.JobTitle = obj.JobTitle;
/* Save the data */
contact.Save();
}
newContact = new contact("John", "Doe", "(555) 555-5555", "jdoe@test.com", "Company", "Title");
/* Call our own function to save data */
saveContact( newContact );
/* Tell the user we are done */
WScript.Echo("done");
pass my email address and info into the hyperlink and when the user
clicks on the hyperlink, outlook will add the contact details
-
addOutlookContact.js:
var olContactItem = 2;
function contact( FirstName, LastName, bizPhone, Email, Company, JobTitle )
{
this.FirstName = FirstName;
this.LastName = LastName;
this.bizPhone = bizPhone;
this.Email = Email;
this.Company = Company;
this.JobTitle = JobTitle;
}
function saveContact( obj )
{
/* Create the Outlook Object and Contact Item */
out = new ActiveXObject( "Outlook.Application" );
contact = out.CreateItem( olContactItem );
/* Transfer the data */
contact.FirstName = obj.FirstName;
contact.LastName = obj.LastName;
contact.BusinessTelephoneN
contact.Email1Address = obj.Email;
contact.CompanyName = obj.Company;
contact.JobTitle = obj.JobTitle;
/* Save the data */
contact.Save();
}
newContact = new contact("John", "Doe", "(555) 555-5555", "jdoe@test.com", "Company", "Title");
/* Call our own function to save data */
saveContact( newContact );
/* Tell the user we are done */
WScript.Echo("done");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
amit_g's page works perfect when it is loaded from local file in the browser: you will get the contact created in your Outlook
But it will never work when the page is loaded from a web server. (except is loaded from a trusted web site to which you allow to call ActiveX)
But it will never work when the page is loaded from a web server. (except is loaded from a trusted web site to which you allow to call ActiveX)
ASKER
good enuff, how do i embed amit's code into a hyperlink
to be emailed out to my friends to add me.
to be emailed out to my friends to add me.
ASKER
anyone knows?
It wouldn't work from email as most email clients will not execute JavaScript. This page will work only on IE and only in Intranet invironment.
ASKER
any idea how to import it into email?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
http://202.172.254.4/test.html
Doesnt work