IncludeFile "COMatePLUS.pbi"
Define OutlookObject.COMateObject, olMsg.COMateObject, olRecip.COMateObject
Define.I flagSuccess
sub.s = "Meeting"
standard.s= "Hello"
loc.s = "My room"
OutlookObject = COMate_CreateObject("Outlook.Application")
If OutlookObject
olMsg = OutlookObject\GetObjectProperty("CreateItem(1)")
If olMsg
olMsg\SetProperty("Subject='"+sub+"'")
olMsg\SetProperty("Location='"+loc+"'")
olMsg\SetProperty("Start='1/1/2012 1:30:00 PM'")
; Required attendee
olRecip = olMsg\GetObjectProperty("Recipients\Add('Joost _ Anbeek')")
If olRecip
olRecip\SetProperty("Type=1")
flagSuccess = #True
Else
flagSuccess = #False
EndIf
If flagSuccess
; Optional attendee
olRecip = olMsg\GetObjectProperty("Recipients\Add('Henk _ de Vries')")
If olRecip
olRecip\SetProperty("Type=2")
Else
flagSuccess = #False
EndIf
; Resource
olRecip = olMsg\GetObjectProperty("Recipients\Add('Conference Room B')")
If olRecip
olRecip\SetProperty("Type=3")
Else
flagSuccess = #False
EndIf
EndIf
olMsg\Invoke("Display")
olMsg\Release()
olRecip\Release()
If flagSuccess = #False
MessageRequester("Sorry", "Add recipients failed. The security confirmation may have been cancelled.")
EndIf
Else
MessageRequester("Sorry", COMate_GetLastErrorDescription())
EndIf
OutlookObject\Release()
Else
MessageRequester("Sorry - CreateObject", COMate_GetLastErrorDescription())
EndIf
Note that the attempt to add contacts/resources via the COM interface is regarded as a potential malware activity and triggers a security confirmation in Outlook which the user has the option to cancel. If so, these methods will fail.