Sometime we may need to import contact from client machine’s outlook, in this case we can write javascript to import outlook contacts easily. Here is the code how to do that.
var Const_olFolderContacts = 10;
var objApp = new ActiveXObject(“Outlook.Application”);
var objNS = objApp.GetNamespace(“MAPI”);
var colContacts = objNS.GetDefaultFolder(Const_olFolderContacts).Items
for( var i=1; i<=colContacts.count;i++)
{
var v = colContacts.item(i);
alert(v[“FullName”]+” (“+v[“Email1Address”]+”)”);
}
if this code does not works , please do the following so it should work
In Internet Explorer , go to Tools | Internet Options | Security -> from ‘Custom Level’ go to ‘Initialize and script ActiveX controls not marked as safe for scripting’ and select ‘Prompt” — this should work now
have got a big detailes code here, you can check this too another code
hi Ashraful,
I need to add contacts to outlook personal address book through javascript code .
Can u help me it urgent
I would like to import the phone, email, fax and title of the outlook contact. Can I use this method to retrieve those values from Outlook 2007?
Ok, the code works, but asume you can “go to Tools | Internet Options | Security …”. If the client aplication run in a pc than we can’t have access (clients of your websites) the code may fail.
My question is, how we can ask or test the IE to know if the option
Tools | Internet Options | Security –> Initialize and script ActiveX controls not marked as safe for scripting
is marked, before run the code?
If you know how to do that, please write me.
hello, I don’t know how to check that option in IE programatically. If you can find it out please let me know.
Thanks
Hi Ashraf,
This code is not working in firefox. Do you have any solution for other browser except IE? Please let me know
Thank you very much
Ehsan,
You may not be able to read outlook activex from firefox.
In that case you need to write activex control.
Thank you for the code.
It saved me.
🙂
hi,
thks for the above code……
now i need a help from u……. im able to add contact in outlook, so how can i use the same to add contact in mozilla thunderbird or any other mail application…… ????
Whilst I really like this post, I believe there was an punctuational error shut towards the end from the third sentence.
can yo hepl me with a java code which can read a mail from outlook and process it., i need it for a project.
hello, I am using a Mac system and i tried this code through my Mac and that has not been successful. Is there any difference between mac and windows code?