Outlook from ASP (or VBScript)

I have an ASP page that has the following code in it:


<script language="VBSCRIPT">

'Add Appointment to Outlook
'ex: onClick="NewAppointment 'Subject','Location','6/1/98 12:00 PM','30'"

Sub NewAppointment(strSubject, strLocation, strStart, strDuration)
      Dim App
    Dim MyNameSpace
    Dim AppointmentFolder
    Dim AppointmentItem
    Dim MailFolder
    Dim MailItem
    Set App = CreateObject("Outlook.Application")    
    Set MyNameSpace = App.GetNamespace("MAPI")
    'Add Appointment
    Set AppointmentFolder = MyNameSpace.GetDefaultFolder(9) 'olFolderCalendar
    Set AppointmentItem = AppointmentFolder.Items.Add
    AppointmentItem.Subject = strSubject
    AppointmentItem.Location = strLocation
      AppointmentItem.Start = strStart
    AppointmentItem.Duration = strDuration
    'Send email
    Set MailFolder = MyNameSpace.GetDefaultFolder(4) 'olFolderInbox
    Set MailItem = MailFolder.Items.Add
    MailItem.To = "joeblow@somewhere.com"
    MailItem.Subject = "New Class Attendee for: " & strSubject
    MailItem.Body = "Date: " & strStart
    Set App = Nothing
    Set MyNameSpace = Nothing
    Set AppointmentFolder = Nothing
    Set AppointmentItem = Nothing
    Set MailFolder = Nothing
    Set MailItem = Nothing

      Msgbox "This event was added to Outlook!"

end SUB

The problem is when it gets to this line:
Set App = CreateObject("Outlook.Application")

It gives me the following error message:
An exception of type "Microsoft VBScript runtime error: ActiveX component can't create object: 'Outlook Application" was not handled.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

MasseyMConnect With a Mentor Commented:
Have you tried Set App = Server.CreateObject("Outlook.Application")

rather than:
Set App = CreateObject("Outlook.Application")

You need to create the object on the server side...  ASP is processed serverside and then sends HTML in response to the request...
Usually what that means is that the dll's needed for Outlook either aren't installed on your server or they've become corrupt or need to be registered.

I would look to make those dll's are in place, in good shape and properly registered.
fatalerror080298Author Commented:
Yea..  They are fine because I can do the same type of thing from Visual Basic just fine..  (Creating Outlook application objects that is)...  I have a feeling I'm just doing it wrong...  But I don't know.. :(
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Are you sure that the Visual Basic application works on the same machine as that of IIS?
fatalerror080298Author Commented:
Sorry it took so long to reply...  I got really busy with something else...  Yes, I can run that exact code in VB and get it to work just fine w/o problems...  (And it is on the same machine as well)
I looked at your solution in th ehope that it would help me. Can anyone help with this error. I would really appreciate it.

Server object error 'ASP 0196 : 80040154'

Cannot launch out of process component

/Mail.asp, line 25

Only InProc server components should be used. If you want to use LocalServer components, you must set the AspAllowOutOfProcComponents metabase setting. Please consult the help file for important considerations
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed.  Also a question is posted there specific to these changes that apply to the experts here.  Also, I am including the link to our All Topics, since many new ones have recently been added.

Thank you,
Moderator @ Experts Exchange
this method "Server.CreateObject("Outlook.Application") " does nothing for me:

Server object, ASP 0177 (0x800401F3)

All Courses

From novice to tech pro — start learning today.