Craigkr
Mar 10th, 2005, 04:31 PM
Hi all
Ok does anyone know how to connect ASP.NET to exchange2003, i an able to do this using VB.NET app, when i try to do it in ASP.NET using VB.NET code behind it doenst work. The code that im using is
Imports System.Reflection
Imports Outlook = Microsoft.Office.Interop.Outlook
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'ListBox1
'
Me.ListBox1.Location = New System.Drawing.Point(96, 80)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(376, 212)
Me.ListBox1.TabIndex = 0
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(96, 40)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(376, 20)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = "TextBox1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(96, 320)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(144, 40)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(552, 397)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.ListBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'test("NOTHING")
Dim x As Integer
Dim arrApptypes As String() = {"StateHolidays", "ParlEvents", "AusHolidays", "Other"}
ListBox1.Items.Clear()
While x < arrApptypes.Length
Dim objApp As Outlook.Items = GetAppointments(arrApptypes(x).ToString)
Dim objAppItem As Outlook.AppointmentItem
For Each objAppItem In objApp
ListBox1.Items.Add(objAppItem.Subject & " >>>" & objAppItem.Start & ">>>>" & objAppItem.Duration)
Next
x = x + 1
End While
End Sub
Function GetAppointments(ByVal AppType As String) As Outlook.Items
' Create Outlook application.
Dim oApp As Outlook.Application = New Outlook.Application
Dim objAppItem As Outlook.AppointmentItem
' Get namespace and Contacts folder reference.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Try
Dim olInbox As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
Dim olItems As Outlook.Items = olInbox.Items
If olItems.Count > 0 Then
Dim strSearch As String = "[Subject] = " & Quote(AppType)
Dim Appointments As Outlook.Items = olItems.Restrict(strSearch)
Return Appointments
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
' Clean up.
'olInbox = Nothing
oApp = Nothing
objAppItem = Nothing
oNS = Nothing
End Try
End Function
Function Quote(ByVal MyText As String)
Quote = Chr(34) & MyText & Chr(34)
End Function
End Class
It returns items from the calendar of outlook on a machine.
I am using VS.NET2003 on an XP machine running IIS, there is no exchange server on this machine and i cant run it on a machine with exchange on it. Any help would be great, being looking for the last few days but have come up with no answers besides components that you need to buy?
Cheers Craig
Ok does anyone know how to connect ASP.NET to exchange2003, i an able to do this using VB.NET app, when i try to do it in ASP.NET using VB.NET code behind it doenst work. The code that im using is
Imports System.Reflection
Imports Outlook = Microsoft.Office.Interop.Outlook
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'ListBox1
'
Me.ListBox1.Location = New System.Drawing.Point(96, 80)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(376, 212)
Me.ListBox1.TabIndex = 0
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(96, 40)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(376, 20)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = "TextBox1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(96, 320)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(144, 40)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(552, 397)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.ListBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'test("NOTHING")
Dim x As Integer
Dim arrApptypes As String() = {"StateHolidays", "ParlEvents", "AusHolidays", "Other"}
ListBox1.Items.Clear()
While x < arrApptypes.Length
Dim objApp As Outlook.Items = GetAppointments(arrApptypes(x).ToString)
Dim objAppItem As Outlook.AppointmentItem
For Each objAppItem In objApp
ListBox1.Items.Add(objAppItem.Subject & " >>>" & objAppItem.Start & ">>>>" & objAppItem.Duration)
Next
x = x + 1
End While
End Sub
Function GetAppointments(ByVal AppType As String) As Outlook.Items
' Create Outlook application.
Dim oApp As Outlook.Application = New Outlook.Application
Dim objAppItem As Outlook.AppointmentItem
' Get namespace and Contacts folder reference.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Try
Dim olInbox As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
Dim olItems As Outlook.Items = olInbox.Items
If olItems.Count > 0 Then
Dim strSearch As String = "[Subject] = " & Quote(AppType)
Dim Appointments As Outlook.Items = olItems.Restrict(strSearch)
Return Appointments
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
' Clean up.
'olInbox = Nothing
oApp = Nothing
objAppItem = Nothing
oNS = Nothing
End Try
End Function
Function Quote(ByVal MyText As String)
Quote = Chr(34) & MyText & Chr(34)
End Function
End Class
It returns items from the calendar of outlook on a machine.
I am using VS.NET2003 on an XP machine running IIS, there is no exchange server on this machine and i cant run it on a machine with exchange on it. Any help would be great, being looking for the last few days but have come up with no answers besides components that you need to buy?
Cheers Craig