Import contacts from outlook with JS

2019-02-28 16:46发布

I need to import contacts from outlook into a web application. I think this is possible to make with JS, but I don't know how. Can anyone give me an example code for my problem?

1条回答
Summer. ? 凉城
2楼-- · 2019-02-28 17:01

you can use activex and javascript to export outlook contacts, but it needs user to enable activex setting in browser, Also Firefox doesnot support activex, so your solution depends on IE. See following example:

function importContacts() {
            try{
                var objOutlook = new ActiveXObject( "Outlook.Application" );
            }
            catch(e){
                alert("Outlook needs to be installed on the machine for data to export.");
                return false;
            }

            ns = objOutlook.GetNamespace("MAPI");

            if( ns )
            {
                als = ns.AddressLists;
                if( als )
                {
                     if( als.count > 0 )
                     {
                           al = als.Item(1); 
                           aes = al.AddressEntries; 
                           for( tmpi = 1; tmpi <= aes.Count; tmpi++)
                           {
                                ae = aes.Item(tmpi); 
                                emai = ae.Address;


                           }
                    }
                }
            }
        }
查看更多
登录 后发表回答