Javascript ActiveX - 自动化服务器无法创建对象

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5157183/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 15:52:34  来源:igfitidea点击:

ActiveX - Automation Server Can't Create Object

javascriptactivex

提问by user70192

I have a web page from which I need to send an email to. I need to send a LARGE email from the browser. Because the content is larger than the query string allows, I need to rely on Active X. I want to send this email through Outlook. In an attempt to do this, I've written the following code:

我有一个需要向其发送电子邮件的网页。我需要从浏览器发送一封大型电子邮件。因为内容比查询字符串允许的要大,所以我需要依赖 Active X。我想通过 Outlook 发送这封电子邮件。为了做到这一点,我编写了以下代码:

try {
  var to = "";
  var cc = "";
  var subject = "Action Required";
  var body = GenerateEmailBody();

  var outlook = new ActiveXObject('Outlook.Application');
  var outlookNamespace = outlook.GetNameSpace('MAPI');

  var message = outlookNamespace.CreateItem(0);
  message.Display();
  message.To = to;
  message.Subject = subject;
  message.Body = body;
  message.GetInspector.WindowState = 2;
} catch (err) {
  alert("Unable to send email. " + err);
}

When I execute this code, I get the following error:

当我执行此代码时,出现以下错误:

ReferenceError: ActiveXObject is not defined 

What am I doing wrong?

我究竟做错了什么?

Thanks!

谢谢!

回答by epascarello

The error "Automation Server Can't Create Object" means that your browser's security settings are too low for the ActiveX control to run. You have to move your page into the trusted sites list and lower the ActiveX settings so it can run.

错误“自动化服务器无法创建对象”意味着您的浏览器的安全设置太低,ActiveX 控件无法运行。您必须将页面移到受信任站点列表中并降低 ActiveX 设置才能运行。

Personally I would avoid ActiveX like the plague since it is locking you into the IE only world. Hence why we still have people stuck with IE6.

就我个人而言,我会像瘟疫一样避免使用 ActiveX,因为它会将您锁定在仅限 IE 的世界中。这就是为什么我们仍然有人坚持使用 IE6。

It you are trying to just preload a mail message, you can use mailto:

如果您只是尝试预加载邮件消息,则可以使用mailto:

回答by Thanga

a) Go to Tools-->Internet Options

a) 转到工具--> Internet 选项

b) Select security tab

b) 选择安全选项卡

c) Click on Trusted Sites (or Local Intranet depending on whether your site is trusted or not)

c) 单击受信任的站点(或本地内联网,具体取决于您的站点是否受信任)

d) Click on Custom Level

d) 点击自定义级别

e) Ensure that "Initialize and script active x controls is not marked safe for scripting" is enabled - this comes under Activex controls and plug-ins section towards 1/4th of the scroll bar.

e) 确保启用“初始化和脚本活动 x 控件未标记为可安全编写脚本” - 这位于滚动条 1/4 处的 Activex 控件和插件部分。

Click OK, OK.

单击确定,确定。

Once this is completed, clear the browser cookies and cache. Close all your browser sessions. Reopen the IE to launch your site.

完成后,清除浏览器 cookie 和缓存。关闭所有浏览器会话。重新打开 IE 以启动您的站点。

Try to disable the setting in step (e) to see if the problem comes back - that should give more insight to the problem.

尝试禁用步骤 (e) 中的设置以查看问题是否再次出现 - 这应该可以更深入地了解问题。

Source : IE9, Automation server can't create object error while using CertEnroll.dll

来源:IE9,自动化服务器在使用 CertEnroll.dll 时无法创建对象错误

回答by Jimmy

You shouldn't be able to create 'Outlook.Application' from within the browser. This could be for a couple of reasons:

您不应该能够从浏览器中创建“Outlook.Application”。这可能有以下几个原因:

  • It is not marked as Safe for Initialisation or Safe for Scripting
  • It has the kill bit set
  • 它没有标记为安全初始化或安全脚本
  • 它设置了kill bit

Can you use a POST to send your email to the server?

您可以使用 POST 将电子邮件发送到服务器吗?

回答by Martijn

The ActiveXObjectobject is only available on Internet Explorer, and it might be subject to restrictions depending on which zone your page is in (local, intranet or internet).

ActiveXObject的对象只在Internet Explorer提供,并根据您的网页是在(本地,Intranet或Internet)的区域可能会受到限制。

Do you want to send an e-mail from a webpage that will be hosted on the internet? Then the only option you have, bar a mailto-link, is sending the e-mail from the server. How to do that is totally dependent on your server-side technology.

您想从将托管在 Internet 上的网页发送电子邮件吗?那么你唯一的选择,除了一个mailto-link,是从服务器发送电子邮件。如何做到这一点完全取决于您的服务器端技术。

回答by B_Rox

make enable , Tools Menu -> Internet Options -> Security -> Custom level -> "Initialize and script ActiveX on IE

启用,工具菜单 -> Internet 选项 -> 安全 -> 自定义级别 ->“在 IE 上初始化和编写 ActiveX 脚本