Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab Outlook Calendar 1

Status
Not open for further replies.

ironhide1975

Programmer
Feb 25, 2003
451
US
Is there an ASP application that can grab an exchange calendar for display on a webpage?

 
Didn't seem to help, are there any ASP classic examples on the web?

 
you will need some COM+ to do that. Write a VB6 dll. I am pretty sure that VB6 has libraries to interact with outlook/exchange calendar, get the data you want passing parameters (such as date of appointmets) to the dll using public variables; the dll in that case will simply get the parameters, query the exchange entry and create html for you.

QatQat

Life is what happens when you are making other plans.
 
Well, if you have never used COM+ then I would suggest you read some tutorials first, to grab the concept. you will need a bit of VB6 Knowledge and obviously a full understanding of how objects work, with all methods and properties because, in fact, you will be writing a custom object for your ASP page.

Checking on my VB6 I found two libraries that could do for you

Microsoft Exchange Event Service Config
Microsoft Outlook XX Object Library

I have no clue about the first one as I hate exchange and use Linux/sendmail as my mail server. Let's try to do something with the latter.


Your VB6 Active X dll Code could be something like the following

Code:
'pass a date for the outlook appoiintments
Public myAppDate as Date

'below an example of a string that you could pass to search among appointments subjects or body

Public mySearch as string


Public Function GetAppointments()



set myOutlook = createobject("Outlook.Application")

set myAppointments = myOutlook.AppointmentItem

'below is my best shot at getting the right date for the appointment
myAppointments.Calendar.Date = myAppDate



now you generate the html string
..dim myHTML as string

myHTML = "<P>myAppointments.Subject</P>"
myHTML = myHTML & "<BR>"<P>myAppointments.Body</P>"



myOutlook = nothing
myAppointments = nothing

'actual action of the function
response.write(myHTML)




end function



Now, the code above is absolutely not tested and I suggest you look for reference about the Outlook Object library but, assuming that it works you then have to save the dll and register it on your system.

If the dll is called Outlook_Apps then the only method of the above object so far is GetAppointments.

Now you write a ASP page that creates the new object

Code:
set myObj = createobject("Outlook_Apps.GetAppointments")

'now you pass the date to the public variable in the dll
myObj.myAppDate = "2006/01/01"


I repeat this is just to point you in the right direction as I have not tested the code, neither the Outlook object; I am sure you can find some reference on the net.


QatQat




Life is what happens when you are making other plans.
 
Ok so I tried the following code in ASP

Code:
   '========================================================
   'CONSTANTS FOR THE CONTAINER RENDERER

   'Time Zone Constants for the US
   CONST CdoDefaultFolderCalendar   = 0
   CONST CdoTmzEastern              = 10
   CONST CdoTmzCentral              = 11
   CONST CdoTmzMountain             = 12
   CONST CdoTmzPacific              = 13
   '========================================================
   'CONTAINER CONSTANT
   CONST CdoClassContainerRenderer  = 3

   strProfileInfo = "serverName" & vbLf & "calendar"
   Set objSession = Server.CreateObject("MAPI.Session")
   objSession.Logon "", "", False, True, 0, True, strProfileInfo
   objSession.SetOption "calendarstore", "outlook"
   Set objRenderApp = Server.CreateObject("AMHTML.application")
   Set objCRenderer = _
      objRenderApp.CreateRenderer(CdoClassContainerRenderer)
   ObjCRenderer.TimeZone = CdoTmzPacific
   objCRenderer.DataSource = _
      objSession.GetDefaultFolder(CdoDefaultFolderCalendar).Messages
   Set objView = ObjCRenderer.Views("Daily Calendar")
   objCRenderer.CurrentView = objView
   objView.RenderAppointments now, Response

I got the following error...

The information store could not be opened. [MAPI 1.0 - [MAPI_E_LOGON_FAILED(80040111)]]
/test.asp, line 22

 
Well I did not think that the MAPI object was part of VBscript.

The message you are getting is clear, LOGON FAILED.
The correct user shoudl be logon before using the MAPI object.

I found some reference that will help you


QatQat




Life is what happens when you are making other plans.
 
I took a look and the only thing I can come up with is that I'm passing the variable wrong.

 
here's more details on that error
Code:
Collaboration Data Objects (0x4F9)
The information store could not be opened. [MAPI 1.0 - [MAPI_E_LOGON_FAILED(80040111)]]
/calendar.asp, line 22

 
if you have omitted the profilename in your session.logon section expecting the system to prompt you for username and password, that will not happen. Remember that you are trying to do everything without COM+ and the example I gave you is just a reference of the CDO session object, not a VBScript example.

Try filling in all profilename and profilepassword keeping ShowDialog set to False. THe showdialog is a way to show a new form in VB6 that cannot be minimized or hidden behind the main form until it is submitted (typically a error form or a login form).

The ShowDialog option in the reference I pointed, if enabled and only in VB, will prompt the operator for a Username and a password when invoking the session.logon method with blank profilename and profilepassword.

If you want to use the VBScript only solution you have to deal with the web constraints; the YOUR_WINDOZ/IUSR is a public user and therefore will not pass any credential to your session.logon method.
Instead of letting CDO trying to handle the login as it would do in VB6, create your own login page and pass the credentials to the session.logon part of your script.
Set newsession to true and Showdialog to false and it will probably work.

CHeers

QatQat

Life is what happens when you are making other plans.
 
I think I understand what you're saying in that I need to modify the query string to access with the appropriate permissions. I believe it should go something like this?

Code:
Set objSession = Server.CreateObject("MAPI.Session")
objSession.Logon([userCalendar],[password],[true],[true],[0],[true],[server]) 
objSession.SetOption "calendarstore", "outlook"



 
Correct, but instead of true true, it should be false false.

Now what I was saying is also that you could create a login screen in asp, store the credentials in two variables

Code:
uName = request("username")
pWord = request("password")


Set objSession = Server.CreateObject("MAPI.Session")
objSession.Logon uName, pWord, false,true, 0, true, server 
objSession.SetOption "calendarstore", "outlook"
This way you will allow every user to access a calendar and not only the one you are hardcoding in the script.


QatQat




Life is what happens when you are making other plans.
 
Ok did that and got this error now
Code:
Collaboration Data Objects (0x43F)
[Collaboration Data Objects - [E_INVALIDARG(80070057)]]

Tried to google it and found very little help with this error. Any thoughts?

 
Hi,

sorry for the delay but I do not check my ASP forum often.

WIll try to understand what that error is and get back to you.


QatQat

Life is what happens when you are making other plans.
 
ironhide, you get this working? I need to do the same thing as you were trying to do.
 
I was able to get a somewhat version of this working in both ASP and ASP.NET however, it was very limited in what it could do. I have no revisited this topic since the project suddenly became unneccessary.

 
Our users use outlook - so I put in a link to call the calendar up from the web page. It opens in outlook.

<a href="outlook:\\Public Folders\All Public Folders\Calendars\National Calendar">National Events</center>

Alot easier than com.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top