开发者

ActiveX - Automation Server Can't Create Object

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:

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: ActiveXObj开发者_开发百科ect is not defined 

What am I doing wrong?

Thanks!


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.

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.

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


a) Go to Tools-->Internet Options

b) Select security tab

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

d) Click on Custom Level

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.

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.

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

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


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

  • It is not marked as Safe for Initialisation or Safe for Scripting
  • It has the kill bit set

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


The ActiveXObject object 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).

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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜