[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VB.NET Reading Outlook Data From Calendar

Posted on 2007-04-03
3
Medium Priority
?
265 Views
Last Modified: 2013-12-25
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.Application")
    Set objNS = objApp.GetNamespace("MAPI")
    'Change OutlookProfileName to the name of your Outlook profile
    objNS.Logon "OutlookProfielName"
    Set objCalendar = objNS.GetDefaultFolder(olFolderCalendar)
   
    '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.ToString).ToString
    Next

However I added the part with the >

The problem is if the calendar has no subject, the program crashes.  Can I fix this?
0
Comment
Question by:Crazy_Penguins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
cavehop earned 2000 total points
ID: 18847209
Probably the easiest way is to check if the Subject exists prior to calling the ToString method.
e.g.
If Not objAppointment.Subject Is Nothing
  TempVal = (objAppointment.Subject.ToString).ToString
Else
  TempVal = "(No Subject)"
End If

Hope this helps,
--Lance--
0
 

Author Comment

by:Crazy_Penguins
ID: 18847549
Thanks Lance!
0
 
LVL 4

Expert Comment

by:cavehop
ID: 18850696
Your most welcome. Glad I could help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question