从Javascript打开Outlook电子邮件客户端

时间:2013-09-18 10:12:49

标签: javascript outlook activex

我正在尝试从下面的javascript打开outlook电子邮件客户端是我正在使用的代码:

function EmailFunctionality(emailTo,emailCcTo,emailSubject,emailBody){
//Reference to Outlook.Application 
var theApp;  
//Outlook.mailItem
var theMailItem; 

//Create a object of Outlook.Application
try {
    //Attach Files to the email
    var attach = "D:\\ADCSIP_source_code\\AnswerForm.pdf";
    var theApp = new ActiveXObject("Outlook.Application");
    var objNS = theApp.GetNameSpace('MAPI');
    var theMailItem = theApp.CreateItem(0); // value 0 = MailItem
    //Bind the variables with the email
    theMailItem.to = (emailTo);
    theMailItem.cc =(emailCcTo);
    theMailItem.Subject = (emailSubject);
    theMailItem.Body = (emailBody);
    theMailItem.Attachments.add(attach);
    theMailItem.display();
}
catch (err) {
    alert("Outlook configuration error."+err.message );
}

}

当我运行此命令并在单击是JS JS代码被调用后,我得到一个activeX安全弹出窗口

并在catch块中显示警告,错误/异常描述为 - “驱动器未就绪,验证磁盘是否在驱动器中并且门已关闭。”

有谁能告诉我哪个驱动器是前景活动X指的?

另外,当我尝试在机器上手动打开Outlook客户端时,我没有收到这样的错误。

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

找到解决方案:这是我的愚蠢错误 -

var attach = "D:\\ADCSIP_source_code\\AnswerForm.pdf";

在上面的代码D中:我所指的不存在。因此它抛出了磁盘不可用的错误。

对不起。

相关问题