Import contacts from outlook with JS

前端 未结 1 706
无人共我
无人共我 2021-01-24 06:14

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条回答
  • 2021-01-24 06:58

    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;
    
    
                               }
                        }
                    }
                }
            }
    
    0 讨论(0)
提交回复
热议问题