Getting specified cast error while taking data from outlook

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vijayasingh
    New Member
    • May 2007
    • 2

    #1

    Getting specified cast error while taking data from outlook

    I am trying to take contacts data from out look and Synchronize with our database. I am using .net 1.1 framework.
    iam using following code.

    OLCont = MyOLList.GetLas t 'CType(item, outlook.Contact Item)
    Do While TypeName(OLCont ) <> "Nothing"
    OLRow = OLTable.NewRow
    OLRow(0) = 0
    OLRow(1) = IIf(OLCont.Firs tName Is Nothing, "", OLCont.FirstNam e)
    OLRow(2) = IIf(OLCont.Midd leName Is Nothing, "", OLCont.MiddleNa me)
    OLRow(3) = IIf(OLCont.Last Name Is Nothing, "", OLCont.LastName )
    OLRow(4) = IIf(OLCont.Full Name Is Nothing, "", OLCont.FullName )
    OLTable.Rows.Ad d(OLRow)
    OLCont = MyOLList.GetPre vious
    Loop


    problem is when i run this code in windows 2000 systems with outlook 2003 running properly. Its retrieving all contacts records from outlook properly

    same code throws "specified cast not valid" error when i run in windows xp (service pack 2 ) with outlook 2003. some contacts records are retrieved but not all.

    while parsing through contacts records only we are getting the above error.

    please help me in this.
  • prabunewindia
    New Member
    • Mar 2007
    • 199

    #2
    hi friend,
    you used one method "IIf"
    is this your pwn method?
    if yes then give that code also?
    and tell me in which line it throwing the error
    Prabu

    Originally posted by vijayasingh
    I am trying to take contacts data from out look and Synchronize with our database. I am using .net 1.1 framework.
    iam using following code.

    OLCont = MyOLList.GetLas t 'CType(item, outlook.Contact Item)
    Do While TypeName(OLCont ) <> "Nothing"
    OLRow = OLTable.NewRow
    OLRow(0) = 0
    OLRow(1) = IIf(OLCont.Firs tName Is Nothing, "", OLCont.FirstNam e)
    OLRow(2) = IIf(OLCont.Midd leName Is Nothing, "", OLCont.MiddleNa me)
    OLRow(3) = IIf(OLCont.Last Name Is Nothing, "", OLCont.LastName )
    OLRow(4) = IIf(OLCont.Full Name Is Nothing, "", OLCont.FullName )
    OLTable.Rows.Ad d(OLRow)
    OLCont = MyOLList.GetPre vious
    Loop


    problem is when i run this code in windows 2000 systems with outlook 2003 running properly. Its retrieving all contacts records from outlook properly

    same code throws "specified cast not valid" error when i run in windows xp (service pack 2 ) with outlook 2003. some contacts records are retrieved but not all.

    while parsing through contacts records only we are getting the above error.

    please help me in this.

    Comment

    • vijayasingh
      New Member
      • May 2007
      • 2

      #3
      Originally posted by prabunewindia
      hi friend,
      you used one method "IIf"
      is this your pwn method?
      if yes then give that code also?
      and tell me in which line it throwing the error
      Prabu

      IIF is not my own method its a in build function in Vb.net

      iam getting error in the following line

      OLCont = MyOLList.GetPre vious

      problem is it not coming windows 2000 system but coming in XP system

      Also if 100 contacts are there means it parse till some 50 then throughing the error. i think the out look object may be corrupting while process through the records. still problem is not solved

      Comment

      Working...