使用脚本写入OUTLOOK联系人

因为客户的强烈要求,需在web中直接将数据库中的用户的联系人直接导入outlook,
部分实现代码如下:

< SCRIPT language = vbscript >
< ! --
Set outLookApp = CreateObject ( " Outlook.Application " )
Set outlookNS = outLookApp.GetNameSpace( " MAPI " )
set theContact = outlookNS.GetDefaultFolder( 10 )
set theContactItems = theContact.Items
set newContact = outLookApp.CreateItem( 2 )

newContact.LastName
= " neolee "
newContact.FirstName
= " huan "
newContact.MobileTelephoneNumber
= " 13588888888 "

newContact.save
alert(newContact.LastName
+ " " + newContact.FirstName + " 成功添加至outlook联系人! " )
//-->
</ SCRIPT >

这段代码本来是用js来写的,但运行却通不过,代码如下:

< SCRIPT language = javascript >
outLookApp
= new ActiveXObject( " Outlook.Application " );
outlookNS
= outLookApp.GetNamespace( " MAPI " );
theContact
= outlookNS.GetDefaultFolder( 10 );
theContactItems
= theContact.Items;
newContact
= outLookApp.CreateItem( 2 );

if (newContact in theContactItems)
alert(
" yes " );
else
alert(
" no " );
</ SCRIPT >


输出结果总是no,不知哪位大侠知道是何原因?

BTW:谢谢kaneboy提出用脚本来实现,本来想用OFFICE PIA来做的,那样就比较麻烦了!:)

你可能感兴趣的:(out)