I've read the thread on the following topic,
Creating Outlook Task from a .NET application in order to create an Outlook Appt for a .NET Web Application. I've gotten it to work as a console application, but not a web application. I'm currently stuck.
I've created an Outlook profile, called "ASPNET" to access my inbox. (I"m developing on my machine). I have "ASPNET" set as the default profile for when Outlook opens up. But, I must be missing something else. I'm currently getting the following error, "The server is not available. Contact your administrator if this condition persists." This is happening when trying to login to the namespace. I have no idea what server the message is talking about. Can anyone help? I've played around and also received the "can't login to MAPI when another MAPI login is happening" (or something like that). I just can't seem to get past this Namespace Logon statement. Please help...
Here's my code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Create an Outlook application.
Dim oApp As Outlook.Application = New Outlook.Application
' Get Mapi NameSpace and Logon.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
oNS.Logon("ASPNET", Missing.Value, False, True) ' TODO:
' Create an AppointmentItem.
Dim oAppt As Outlook._AppointmentItem = oApp.CreateItem(Outlook.OlItemType.olAppointmentItem)
' Change AppointmentItem to a Meeting.
oAppt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting
' Set some common properties.
oAppt.Subject = "Created using OOM in VB.NET"
oAppt.Body = "Hello World"
oAppt.Location = "Samm E"
oAppt.Start = Convert.ToDateTime("04/15/2004 9:00:00 AM")
oAppt.End = Convert.ToDateTime("04/15/2004 1:00:00 PM")
oAppt.ReminderSet = True
oAppt.ReminderMinutesBeforeStart = 5
oAppt.BusyStatus = Outlook.OlBusyStatus.olBusy ' olBusy
oAppt.IsOnlineMeeting = False
oAppt.AllDayEvent = False
' Add attendees.
Dim oRecipts As Outlook.Recipients = oAppt.Recipients
' Add required attendee.
Dim oRecipt As Outlook.Recipient
oRecipt = oRecipts.Add("DS Change Request Calendaar") ' TODO:
oRecipt.Type = Outlook.OlMeetingRecipientType.olRequired
'' Add optional attendee.
'oRecipt = oRecipts.Add("UserTest2") ' TODO:
'oRecipt.Type = Outlook.OlMeetingRecipientType.olOptional
' Send out request.
' Clean up.
oApp = Nothing
oNS = Nothing
oAppt = Nothing
oRecipts = Nothing
oRecipt = Nothing