Link to home
Start Free TrialLog in
Avatar of bizjosh
bizjoshFlag for Singapore

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.BusinessTelephoneNumber = 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");
ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bizjosh

ASKER

Errors on page:

http://202.172.254.4/test.html

Doesnt work
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)
Avatar of bizjosh

ASKER

good enuff, how do i embed amit's code into a hyperlink
to be emailed out to my friends to add me.
Avatar of bizjosh

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.
Avatar of bizjosh

ASKER

any idea how to import it into email?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial