Link to home
Start Free TrialLog in
Avatar of Knight905416
Knight905416

asked on

Outlook: COMException: Cannot load free/busy information

Does anyone know how to return Free/Busy information from Outlook only, no Exchange server.

The error I am getting:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in BusinessTier.dll
System.Runtime.InteropServices.COMException (0x80020009): Cannot load free/busy information.
   at Microsoft.Office.Interop.Outlook.Recipient.FreeBusy(DateTime Start, Int32 MinPerChar, Object CompleteFormat)
   at BusinessTier.FEFC.Email.FindFreeTimeInOutlook() in C:\Files\CompanyName\ProjectName\FEFCBusinessTier\Email.vb:line 307

I'm connected to incoming mail server is imap.gmail.com and outgoing is smtp.gmail.com and I can send email from the Imports Microsoft.Office.Interop reference.

This code is working (with errors commented):

Dim objOutlook As Outlook.Application = Nothing
Dim objNS As Outlook.NameSpace = Nothing
Dim objRecipient As Outlook.Recipient
Dim objMissing As Object = Type.Missing
Dim dtStartDate As Date = #6/22/2015#
Dim dt As DateTime = DateTime.Now
objOutlook = New Outlook.Application()
objNS = objOutlook.GetNamespace("MAPI")
objNS.Logon(objMissing, objMissing, False, False)
objMail = CType(objOutlook.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)
With objMail
.Subject = "Testing of Free/Busy Functionality"
.To = "yourinfo@domain.com"
.Body = "This is a test email before testing the Free/Busy functionality of Outlook."
.Send()'successfully sends email
End With

objRecipient = objNS.CreateRecipient("yourinfo@domain.com")
Try
strFreeBusyData = objRecipient.FreeBusy(dt, 60) 'Throws error
Catch ex As Exception
Debug.Print(ex.ToString)
End Try

Dim oAddressEntries As Outlook.AddressEntries = Nothing
Dim oAddressEntry As Outlook.AddressEntry
Try
oAddressEntry = oAddressEntries("yourinfo@domain.com")
strFreeBusyData = oAddressEntry.GetFreeBusy(dtStartDate, 30)'error again
Catch ex As Exception
Debug.Print(ex.ToString)
End Try

I published calendar settings to a WebDAV server and have a .ics file created.  But can not get the above 2 methods to work.  My other option is to interpret the .ics file myself.  Does anyone know the .ics layout and what the data means.  I can figure out the dates, but the times are lost to me.  It looks like this:

BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
X-CALSTART:20150921T190000Z
X-CALEND:20150923T210000Z
X-CLIPSTART:20150921T040000Z
X-CLIPEND:20151122T050000Z
X-WR-RELCALID:{00000018-88A0-717B-F7FC-E00880CFE831}
X-WR-CALNAME:info@domain
X-WR-CALDESC:Calendar Comment
X-PRIMARY-CALENDAR:TRUE
X-PUBLISHED-TTL:PT60M
X-OWNER;CN=info@domain:mailto:info@domain.com
X-MS-OLK-WKHRSTART;TZID="Eastern Standard Time":100000
X-MS-OLK-WKHREND;TZID="Eastern Standard Time":200000
X-MS-OLK-WKHRDAYS:MO,TU,WE,TH,FR
BEGIN:VTIMEZONE
TZID:Eastern Standard Time
BEGIN:STANDARD
DTSTART:16011104T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010311T020000
RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTEND:20150921T200000Z
DTSTAMP:20150922T143608Z
DTSTART:20150921T190000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Busy
TRANSP:OPAQUE
UID:z87ztC0NYEOQhHog7Ut1JQ==
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
DTEND:20150921T213000Z
DTSTAMP:20150922T143608Z
DTSTART:20150921T210000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Busy
TRANSP:OPAQUE
UID:A42kagODykSr0F8sAAC85g==
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
DTEND:20150922T160000Z
DTSTAMP:20150922T143608Z
DTSTART:20150922T153000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Busy
TRANSP:OPAQUE
UID:QZvGc4Val0+g2uda+9G9Hw==
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
DTEND:20150922T210000Z
DTSTAMP:20150922T143608Z
DTSTART:20150922T180000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Busy
TRANSP:OPAQUE
UID:PdGDKQaQEU2kCq3qEEDhhA==
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
DTEND:20150923T173000Z
DTSTAMP:20150922T143608Z
DTSTART:20150923T170000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Busy
TRANSP:OPAQUE
UID:W+Zibfl7KUyhPnnTR8+EFQ==
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
DTEND:20150923T210000Z
DTSTAMP:20150922T143608Z
DTSTART:20150923T190000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Busy
TRANSP:OPAQUE
UID:2FMbtw1rxUyy/UgWHooi0Q==
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
END:VCALENDAR

Thanks in advance for anyone's help!
ASKER CERTIFIED SOLUTION
Avatar of Knight905416
Knight905416

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial