A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Outlook » Calendar
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

"Cast not valid" error while getting Appointments from outlook(VB.



 
 
Thread Tools Display Modes
  #1  
Old March 18th, 2005, 09:31 AM
xyz
external usenet poster
 
Posts: n/a
Default "Cast not valid" error while getting Appointments from outlook(VB.

Hello,
I am writing a VB.Net application, wherein I am trying to get
appointments from outlook. The problem i am facing is that,sometimes i am
getting an error: "Cast not valid" for the line
myAppt = myAppts.GetFirst().
I have observed that i get this error mostly, when i already have the
outlook open.
Can anyone help me to overcome this problem?

Here is the piece of code:
Dim myolApp As New outlook.Application
Dim olNs As outlook.NameSpace
olNs = myolApp.GetNamespace("MAPI")
olNs.Logon(, , , False)

Dim myAppts As outlook.Items
Dim myAppt As outlook.AppointmentItem
myAppts =
olNs.GetDefaultFolder(outlook.OlDefaultFolders.olF olderCalendar).Items
'''''' Restricting the no. of appointments to get to a range of 20 days
around today''''
myAppt = myAppts.GetFirst()
Do While TypeName(myAppt) "Nothing"
''''Saving the appointments '''''''''
myAppt = myAppts.GetNext()
Loop
olNs = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComO bject(myolApp)

--
Thank you,
xyz
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ANNOUNCEMENT: WS:Repeat Appointments II on General Release Websetters Calendar 0 February 9th, 2005 09:51 PM
I can't open existing appointments or create new appointments in . Marissa Calendar 1 November 19th, 2004 04:03 PM
Group calendar stranegly loses appointments a while after theire m Tim de Jager Calendar 1 July 21st, 2004 04:51 PM
appointments disappear and re-appear randomly Steve Zito Calendar 2 June 14th, 2004 09:34 PM
Private appointments shown in teamcal.htm (teamcalendar) Gertjan en Piet Calendar 0 April 29th, 2004 12:47 PM


All times are GMT +1. The time now is 07:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.