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.InteropSer vices.COME xception' occurred in BusinessTier.dll
System.Runtime.InteropServ ices.COMEx ception (0x80020009): Cannot load free/busy information.
at Microsoft.Office.Interop.O utlook.Rec ipient.Fre eBusy(Date Time Start, Int32 MinPerChar, Object CompleteFormat)
at BusinessTier.FEFC.Email.Fi ndFreeTime InOutlook( ) in C:\Files\CompanyName\Proje ctName\FEF CBusinessT ier\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("M API")
objNS.Logon(objMissing, objMissing, False, False)
objMail = CType(objOutlook.CreateIte m(Outlook. OlItemType .olMailIte m), 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("you rinfo@doma in.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( dtStartDat e, 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:20150921T190000 Z
X-CALEND:20150923T210000Z
X-CLIPSTART:20150921T04000 0Z
X-CLIPEND:20151122T050000Z
X-WR-RELCALID:{00000018-88 A0-717B-F7 FC-E00880C FE831}
X-WR-CALNAME:info@domain
X-WR-CALDESC:Calendar Comment
X-PRIMARY-CALENDAR:TRUE
X-PUBLISHED-TTL:PT60M
X-OWNER;CN=info@domain:mai lto:info@d omain.com
X-MS-OLK-WKHRSTART;TZID="E astern Standard Time":100000
X-MS-OLK-WKHREND;TZID="Eas tern 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=1S U;BYMONTH= 11
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010311T020000
RRULE:FREQ=YEARLY;BYDAY=2S U;BYMONTH= 3
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTEND:20150921T200000Z
DTSTAMP:20150922T143608Z
DTSTART:20150921T190000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Bus y
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:Bus y
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:Bus y
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:Bus y
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:Bus y
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:Bus y
TRANSP:OPAQUE
UID:2FMbtw1rxUyy/UgWHooi0Q ==
X-MICROSOFT-CDO-BUSYSTATUS :BUSY
END:VEVENT
END:VCALENDAR
Thanks in advance for anyone's help!
The error I am getting:
A first chance exception of type 'System.Runtime.InteropSer
System.Runtime.InteropServ
at Microsoft.Office.Interop.O
at BusinessTier.FEFC.Email.Fi
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("M
objNS.Logon(objMissing, objMissing, False, False)
objMail = CType(objOutlook.CreateIte
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("you
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@
strFreeBusyData = oAddressEntry.GetFreeBusy(
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:20150921T190000
X-CALEND:20150923T210000Z
X-CLIPSTART:20150921T04000
X-CLIPEND:20151122T050000Z
X-WR-RELCALID:{00000018-88
X-WR-CALNAME:info@domain
X-WR-CALDESC:Calendar Comment
X-PRIMARY-CALENDAR:TRUE
X-PUBLISHED-TTL:PT60M
X-OWNER;CN=info@domain:mai
X-MS-OLK-WKHRSTART;TZID="E
X-MS-OLK-WKHREND;TZID="Eas
X-MS-OLK-WKHRDAYS:MO,TU,WE
BEGIN:VTIMEZONE
TZID:Eastern Standard Time
BEGIN:STANDARD
DTSTART:16011104T020000
RRULE:FREQ=YEARLY;BYDAY=1S
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010311T020000
RRULE:FREQ=YEARLY;BYDAY=2S
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTEND:20150921T200000Z
DTSTAMP:20150922T143608Z
DTSTART:20150921T190000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Bus
TRANSP:OPAQUE
UID:z87ztC0NYEOQhHog7Ut1JQ
X-MICROSOFT-CDO-BUSYSTATUS
END:VEVENT
BEGIN:VEVENT
DTEND:20150921T213000Z
DTSTAMP:20150922T143608Z
DTSTART:20150921T210000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Bus
TRANSP:OPAQUE
UID:A42kagODykSr0F8sAAC85g
X-MICROSOFT-CDO-BUSYSTATUS
END:VEVENT
BEGIN:VEVENT
DTEND:20150922T160000Z
DTSTAMP:20150922T143608Z
DTSTART:20150922T153000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Bus
TRANSP:OPAQUE
UID:QZvGc4Val0+g2uda+9G9Hw
X-MICROSOFT-CDO-BUSYSTATUS
END:VEVENT
BEGIN:VEVENT
DTEND:20150922T210000Z
DTSTAMP:20150922T143608Z
DTSTART:20150922T180000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Bus
TRANSP:OPAQUE
UID:PdGDKQaQEU2kCq3qEEDhhA
X-MICROSOFT-CDO-BUSYSTATUS
END:VEVENT
BEGIN:VEVENT
DTEND:20150923T173000Z
DTSTAMP:20150922T143608Z
DTSTART:20150923T170000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Bus
TRANSP:OPAQUE
UID:W+Zibfl7KUyhPnnTR8+EFQ
X-MICROSOFT-CDO-BUSYSTATUS
END:VEVENT
BEGIN:VEVENT
DTEND:20150923T210000Z
DTSTAMP:20150922T143608Z
DTSTART:20150923T190000Z
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:Bus
TRANSP:OPAQUE
UID:2FMbtw1rxUyy/UgWHooi0Q
X-MICROSOFT-CDO-BUSYSTATUS
END:VEVENT
END:VCALENDAR
Thanks in advance for anyone's help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.