Crazy_Penguins
asked on
VB.NET Reading Outlook Data From Calendar
I am using this code from another solution on this site:
'In your project include a reference to Microsoft Outlook x.x Object Library
'where x.x is your version of Outlook
Dim objApp As Outlook.Application, _
objNS As Outlook.NameSpace, _
objCalendar As Outlook.MAPIFolder, _
objAppointment As Outlook.AppointmentItem
Set objApp = CreateObject("Outlook.Appl ication")
Set objNS = objApp.GetNamespace("MAPI" )
'Change OutlookProfileName to the name of your Outlook profile
objNS.Logon "OutlookProfielName"
Set objCalendar = objNS.GetDefaultFolder(olF olderCalen dar)
'To access each appointment in the calendar do this
For Each objAppointment In objCalendar.Items
'Code to do whatever you want to do with each appointment
> TempVal = (objAppointment.Subject.To String).To String
Next
However I added the part with the >
The problem is if the calendar has no subject, the program crashes. Can I fix this?
'In your project include a reference to Microsoft Outlook x.x Object Library
'where x.x is your version of Outlook
Dim objApp As Outlook.Application, _
objNS As Outlook.NameSpace, _
objCalendar As Outlook.MAPIFolder, _
objAppointment As Outlook.AppointmentItem
Set objApp = CreateObject("Outlook.Appl
Set objNS = objApp.GetNamespace("MAPI"
'Change OutlookProfileName to the name of your Outlook profile
objNS.Logon "OutlookProfielName"
Set objCalendar = objNS.GetDefaultFolder(olF
'To access each appointment in the calendar do this
For Each objAppointment In objCalendar.Items
'Code to do whatever you want to do with each appointment
> TempVal = (objAppointment.Subject.To
Next
However I added the part with the >
The problem is if the calendar has no subject, the program crashes. Can I fix this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your most welcome. Glad I could help.
ASKER