Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2007, 01:39 AM
Authorized User
 
Join Date: Jan 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default InvalidCastException in VB.NET?

I am writing a code in VB.NET to access MS Outlook folders.Its giving all the folders and their msgs but when any calender meeting or any other things other than the mails appears any the folders like deleted items ,Inbox etc. then it shows Invalid cast exception in line

oMsg = oItems.Item(i)

in the following code.

and the loop stops executing.What is the solution for tht?

Dim oItems As Microsoft.Office.Interop.Outlook.Items = sfolder.Items

Dim oMsg As Microsoft.Office.Interop.Outlook.MailItem

Dim i As Integer

For i = 1 To oItems.Count

Try

oMsg = oItems.Item(i)

s.WriteLine("<li>")

s.WriteLine("<a href=ConsoleApplication1.vb?oPFolder=Personal Folders&sFolder=Inbox&oMsg=i>" + oMsg.Subject + "</a>")

s.WriteLine("</li>")

Catch ex As InvalidCastException

Console.WriteLine("Caught:InvalidCastException", ex)

End Try







Similar Threads
Thread Thread Starter Forum Replies Last Post
System.InvalidCastException: Specified cast is not scslarry BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 6 January 18th, 2007 07:34 PM
PhileIdentity - System.InvalidCastException terencetham BOOK: ASP.NET Website Programming Problem-Design-Solution 6 September 25th, 2006 02:27 PM
'System.InvalidCastException' Problem! Please help CyberGeek ADO.NET 0 March 19th, 2006 03:14 PM
System.InvalidCastException: Specified cast is not chiefg BOOK: ASP.NET Website Programming Problem-Design-Solution 2 March 2nd, 2004 01:29 PM
InvalidCastException in Serviced Component schockp VS.NET 2002/2003 1 September 3rd, 2003 02:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.