Click here to Skip to main content
16,014,952 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: want mysql+vb.net application Pin
Christian Graus17-Jan-07 0:22
protectorChristian Graus17-Jan-07 0:22 
AnswerRe: want mysql+vb.net application Pin
Vinay Dornala17-Jan-07 0:59
Vinay Dornala17-Jan-07 0:59 
GeneralRe: want mysql+vb.net application [modified] Pin
priya_p23317-Jan-07 2:27
priya_p23317-Jan-07 2:27 
GeneralRe: want mysql+vb.net application Pin
Jason McBurney17-Jan-07 6:29
Jason McBurney17-Jan-07 6:29 
QuestionShow Table name Pin
Socheat.Net16-Jan-07 23:57
Socheat.Net16-Jan-07 23:57 
AnswerRe: Show Table name Pin
Jason McBurney17-Jan-07 6:39
Jason McBurney17-Jan-07 6:39 
Questionunknown software exception on closedown Pin
Ben Dessau16-Jan-07 23:03
Ben Dessau16-Jan-07 23:03 
Questionurgent!!!!!!!!!problem in VB.NET Pin
salon16-Jan-07 22:29
salon16-Jan-07 22:29 
Sigh | :sigh: I wrote a code in VB.NET which accesses the outlook folders.Following is the code.According to this code it displays outlook folders and there is hyperlink on each subject.I want when we click on the subject the message body should be dispalyed.in href how can we do this? I know we have to write a function to dispalay the body.but i don't know how to do this?can u please tell me ?
an exception Invalid cast exception is coming in this line

oMsg = oItems.Item(i)

it means when we access the folders and suppose the folder contains a calender meeting items i.e. another cast or datatype then the inner loop stops executing.
please tell me to handle this exception?
code is like this

we ahve to add a refernce Microsoft outlook 11.0 library from Project->add reference -> COM tab and the code is this please help me?
Imports System.Runtime.InteropServices
Imports

Microsoft.Office.Interop.Outlook
Imports

System.IO
Module

Module1

Sub Main()

'OlSecurityManager.DisableOOMWarnings = True

Try

' Create Outlook application.

Dim app As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application

' Get NameSpace and Logon.

Dim appNameSpace As Microsoft.Office.Interop.Outlook.NameSpace = app.GetNamespace("MAPI")
appNameSpace.Logon("Outlook", "bhavna123",

False, True)

' Get Messages collection of Inbox.

Dim fs As New FileStream("c:\Outlook_Folders.htm", FileMode.Create, FileAccess.Write)

Dim s As New StreamWriter(fs)

Dim oPFolder As Microsoft.Office.Interop.Outlook.MAPIFolder = appNameSpace.Folders.GetFirst()

Dim oFol As Microsoft.Office.Interop.Outlook.Folders = oPFolder.Folders

Dim sfolder As Microsoft.Office.Interop.Outlook.MAPIFolder

Dim j As Integer

For j = 1 To oFol.Count
sfolder = oFol.Item(j)

s.WriteLine("
  • ")

    s.WriteLine(sfolder.Name)

    s.WriteLine("
  • ")

    s.WriteLine("
      ")


      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("
    • ")

      s.WriteLine("" + oMsg.Subject + "")

      s.WriteLine("
    • ")


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


      'Ignore any invalid casts.

      End Try

      Next
      s.WriteLine("
    ")

    s.WriteLine("")


    Next
    s.Close()

    fs =

    New FileStream("c:\Outlook_Folders.htm", FileMode.Open, FileAccess.Read)

    Dim d As New StreamReader(fs)
    d.BaseStream.Seek(0, SeekOrigin.Begin)




    'LogOff
    appNameSpace.Logoff()


    'cleanup
    app =

    Nothing
    appNameSpace =

    Nothing

    'oItems = Nothing
    Console.ReadLine()


    Catch exc As ApplicationException
    Console.WriteLine("Caught:ApplicationException", exc)


    'Finally

    ' OlSecurityManager.DisableOOMWarnings = False

    End Try

    End Sub
    End

    Module
    QuestionSearching in datasets or datatables Pin
    WofR16-Jan-07 22:11
    WofR16-Jan-07 22:11 
    AnswerRe: Searching in datasets or datatables Pin
    shreekar16-Jan-07 23:20
    shreekar16-Jan-07 23:20 
    AnswerRe: Searching in datasets or datatables Pin
    MatthysDT17-Jan-07 0:05
    MatthysDT17-Jan-07 0:05 
    AnswerRe: Searching in datasets or datatables Pin
    Jason McBurney17-Jan-07 6:50
    Jason McBurney17-Jan-07 6:50 
    Questionpromblem Pin
    ravimwani16-Jan-07 21:33
    ravimwani16-Jan-07 21:33 
    AnswerRe: promblem Pin
    Christian Graus17-Jan-07 0:22
    protectorChristian Graus17-Jan-07 0:22 
    AnswerRe: promblem Pin
    Jason McBurney17-Jan-07 6:52
    Jason McBurney17-Jan-07 6:52 
    Questionquery in vb.net [modified] Pin
    amaneet16-Jan-07 21:24
    amaneet16-Jan-07 21:24 
    AnswerRe: query in vb.net Pin
    Guffa16-Jan-07 22:01
    Guffa16-Jan-07 22:01 
    GeneralRe: query in vb.net [modified] Pin
    amaneet16-Jan-07 22:25
    amaneet16-Jan-07 22:25 
    GeneralRe: query in vb.net Pin
    nlarson1117-Jan-07 4:20
    nlarson1117-Jan-07 4:20 
    QuestionGlobal Error Handling Pin
    MatthysDT16-Jan-07 20:58
    MatthysDT16-Jan-07 20:58 
    AnswerRe: Global Error Handling Pin
    Dave Sexton17-Jan-07 0:25
    Dave Sexton17-Jan-07 0:25 
    AnswerRe: Global Error Handling Pin
    Christian Graus17-Jan-07 0:35
    protectorChristian Graus17-Jan-07 0:35 
    QuestionVertical Label Pin
    Laji5916-Jan-07 20:36
    Laji5916-Jan-07 20:36 
    AnswerRe: Vertical Label Pin
    MatthysDT17-Jan-07 0:50
    MatthysDT17-Jan-07 0:50 
    QuestionCan I make a Crystal Report using dataview Pin
    hisuman10016-Jan-07 20:08
    hisuman10016-Jan-07 20:08 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.