I'm working on a system integrating Novell Groupwise with Excel using VBA. So far I create and send appointments in Groupwise through Excel. I now want to be able to delete appointments in Groupwise.

Here's the code I have:

Sub DeleteAppt()

Set gwApplication = CreateObject("NovellGroupWareSession")
Set gwAccount = gwApplication.Login()

'Get old message
Dim gwRetrievedMsg
Set gwRetrievedMsg = gwAccount.MailBox.Messages.Item("messageIDhere")

'Delete message

End Sub
So far I've just been manually entering messageIDs for different emails to test how the code works.
When the messageID input is of an email I sent, the code runs fine and deletes the email as desired. But when the messageID is of an appointment I sent, I get Run-time error '91': Object variable or With block variable not set. The debugger takes me to the "gwRetrievedMsg.Delete" line.

I thought it must have something to do with the difference between a normal email message and an appointment message. However, the code runs fine when the messageID is of an appointment sent by someone other than myself.

If anyone could shed some light about why I am getting this run-time error, it'd be very appreciated.