0

I am trying to send email in VB.Net using outlook 2013. I tested as localhost in debug mode and everything is fine. I can send and read Outlook emails in vb.net. However, when I publish the web application and click the send button I get the following exception:

System.Exception: Cannot create ActiveX component. at Microsoft.VisualBasic.Interaction.CreateObject(String ProgId, String ServerName).

This code gives me the error.

Dim tempApp As Outlook.Application
tempApp = CType(CreateObject("Outlook.Application"), Outlook.Application)

I have tried using.

Dim tempApp As New Outlook.Application

no luck this way either. I have done some searching for this problem and have tried the following solutions given to similar issues and still no fix: ASP.NET Cannot create ActiveX component Cannot create Active X Object

I will do my best to solve this issue and post up any findings I get.

Community
  • 1
  • 1
Tamati
  • 11
  • 1
  • 7
  • It is a horrible idea to use Office Interop from ASP.NET or another server technology. These APIs were written for use in a desktop application, for automating Office (a suite of desktop applications). Server applications are different in many ways that make it a very, very bad idea to use Office Interop in them. It's also unsupported by Microsoft, and may violate your Office license. See [Considerations for server-side Automation of Office](http://support.microsoft.com/kb/257757) – John Saunders Jun 16 '15 at 01:31
  • Haha did not know that. Thanks man. – Tamati Jun 16 '15 at 02:10
  • Also even if it did run it would run on the server's computer not the user computer. At worse you could use javascript in an html page to do it but the user security settings would have to be extremely slack. Thnik about it - as a user do you really want to let any random webpage control your Outlook software???? – Mystra007 Jun 16 '15 at 03:10

1 Answers1

1

No Office app (including Outlook) can run in a service (such as IIS). Your options are Extended MAPI (C++ or Delphi only), Redemption (I am its author, it wraps Extended MAPI and can be accessed from any language, including C#), EWS (Exchange only) or straight SMTP.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Thanks Dmitry. I had no idea about that. I was just reading through the following link trying to find a solution but yeah I will go ahead with SMTP. – Tamati Jun 16 '15 at 02:08
  • Dmitry it can works in a page served by IIS as long as you use Javascript. Sometimes in corporate environment using javascript in an html page on the Intranet is the only option. OP might be in one of these situation. – Mystra007 Jun 16 '15 at 03:13
  • @Mystra007: But then the code is not running under IIS, it is running as a client side JavaScript, which only works under IE if the server was added to the safe list. And the OP would not be able to use VB.Net, only VB Script. – Dmitry Streblechenko Jun 16 '15 at 05:09