Problem creating appointment programmatically after applying Office 2003 SP2

Problem creating appointment programmatically after applying Office 2003 SP2

Post by rube » Sun, 19 Feb 2006 02:14:28


Hi all,

I tried this post some time ago but I had no fruitful answer. Maybe now
someone else has experienced the same thing.

I have an access application (adp) that is used to create appointments in
outlook (through some VB6 code). There's also some VB application that uses
the same code.

The application works fine in Office 2003 SP1, but when I installed SP2 I
got some strange behaviour. In my form I can select which calendar I want to
create appointments in. If I select other employees, everything is fine.
When I select my own calendar the line:

oAppt = olCalendar.Items.Add

fails with some unhelpful error message (can't remember exactly but
something like abnormal termination). I uninstalled SP2 and the application
is working perfectly again.

I tried creating some simple function just to test this behaviour in my
calendar. I replaced the lines with calls to "CreateRecipient" and
"GetSharedDefaultFolder" with calls to "GetDefaultFolder" instead. But to no
avail.

Needless to say, it's not a problem of permissions, for the application
works with SP1 and I can create appts in my outlook.

I hope someone can shed some light,
Thanks,

Ruben

This is my code:
----------------------------
Dim oApp As Outlook.Application
Dim golNameSpace As Outlook.NameSpace
Dim oAppt As Outlook.AppointmentItem
Dim myRecipient As Outlook.Recipient
Dim olCalendar As Outlook.MAPIFolder
Dim strOutlookKey As String

oApp = New Outlook.Application
golNameSpace = oApp.GetNamespace("MAPI")
strOutlookKey = strDate & employee & Rnd()

Try
myRecipient = golNameSpace.CreateRecipient(employee) ' employee is a
'string with the employee's username
olCalendar = golNameSpace.GetSharedDefaultFolder(myRecipient,
olFolderCalendar)
oAppt = olCalendar.Items.Add

' Set some common properties.
oAppt.Subject = "Subject"
oAppt.Body = "Body of the appt here"
oAppt.Start = Convert.ToDateTime(strDate & " 0:00:00")
oAppt.End = Convert.ToDateTime(strDate & " 23:59:00")
oAppt.ReminderSet = False
oAppt.BusyStatus = Outlook.OlBusyStatus.olOutOfOffice
oAppt.IsOnlineMeeting = False
oAppt.AllDayEvent = True

' Save to Employee's Calendar.
oAppt.Save()
Catch
MsgBox("Error Saving Appointment, check that you are authorised to write
in the calendar - " & Err.Description)
End Try
------------------------------
 
 
 

Problem creating appointment programmatically after applying Office 2003 SP2

Post by Sue Mosher » Sun, 19 Feb 2006 06:50:14

his is VB.NET, not VB6 code, right? To create an item in your own calendar, you don't need to use Items.Add or GetDefaultFolder. Just use Application.CreateItem.

If you prefer to work with the folder, replace:

myRecipient = golNameSpace.CreateRecipient(employee) ' employee is a
'string with the employee's username
olCalendar = golNameSpace.GetSharedDefaultFolder _
(myRecipient, olFolderCalendar)
oAppt = olCalendar.Items.Add

with

olCalendar = golNameSpace.GetDefaultFolder, olFolderCalendar)
oAppt = olCalendar.Items.Add

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"ruben" < XXXX@XXXXX.COM > wrote in message news:43f604a4.0@entanet...

 
 
 

Problem creating appointment programmatically after applying Office 2003 SP2

Post by rube » Wed, 22 Feb 2006 01:04:05

hanks for your help, Sue.

I downloaded again SP2 and now it all worked fine with both with my old code
and yours. Weird.
So it's either: MS has released an updated version of Office 2003 SP2 (my
WSUS has 3 versions of it)
or I didn't restart after applying the patch the last time.

Cheers,
Ruben


"Sue Mosher [MVP-Outlook]" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
This is VB.NET, not VB6 code, right? To create an item in your own calendar,
you don't need to use Items.Add or GetDefaultFolder. Just use
Application.CreateItem.

If you prefer to work with the folder, replace:

myRecipient = golNameSpace.CreateRecipient(employee) ' employee is a
'string with the employee's username
olCalendar = golNameSpace.GetSharedDefaultFolder _
(myRecipient, olFolderCalendar)
oAppt = olCalendar.Items.Add

with

olCalendar = golNameSpace.GetDefaultFolder, olFolderCalendar)
oAppt = olCalendar.Items.Add

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"ruben" < XXXX@XXXXX.COM > wrote in message
news:43f604a4.0@entanet...
uses
to
application
no