Click here to Skip to main content
       

Visual Basic

 
AnswerRe: Web interface to access application Pinmemberwaner michaud26-Feb-13 3:19 
AnswerRe: Web interface to access application Pinmemberwaner michaud26-Feb-13 5:40 
GeneralRe: Web interface to access application PinmvpSandeep Mewara26-Feb-13 5:52 
GeneralRe: Web interface to access application Pinmemberwaner michaud26-Feb-13 6:54 
AnswerRe: Web interface to access application PinmvpEddy Vluggen26-Feb-13 9:25 
QuestionListbox String to RichTextbox. Help Please! PinmemberJanko199322-Feb-13 17:14 
AnswerRe: Listbox String to RichTextbox. Help Please! PinmvpRichard MacCutchan22-Feb-13 23:21 
AnswerRe: Listbox String to RichTextbox. Help Please! PinmemberTnTinMN24-Feb-13 13:24 
You appear to have extracted all the relevant information for the message, but the only thing you are storing in the ListBox items collection is the from and and subject parts as a single string.
 
ListBox1.Items.Add(strFrom & ", " & strSubject)
 
I would suggest that instead of storing this string, that you instead define a class to hold the relevant information.
 
Something like this:
Public Class MessageItem
   Public From As String
   Public Body As String
   Public Subject As String
   Public Sub New(ByVal From As String, ByVal Subject As String, ByVal Body As String)
      Me.From = From
      Me.Body = Body
      Me.Subject = Subject
   End Sub
      Public Overrides Function ToString() As String
         Return From & ", " & Subject
      End Function
End Class
 
Instead of adding items directly to the ListBox, you bind the ListBox to a List(of MessageItem). Define this list at the form level like this:
 
Private Messages As New List(Of MessageItem)
 
In the FormLoad event handler, place this statement:
 
ListBox1.DataSource = Messages
 
The ToString Function defined in the class will provide the text displayed for the item in the ListBox.
 
Now in your button_click handler, replace this code:
                'call the functions to get the various parts out of the email
                strFrom = mailMess.ParseEmail(strMailContent, "From:")
                strSubject = mailMess.ParseEmail(strMailContent, "Subject:")
                strToo = mailMess.ParseEmail(strMailContent, "To:")
                strBody = mailMess.ParseBody()
 
                'add email details to the list box
                ListBox1.Items.Add(strFrom & ", " & strSubject)
 
with this:
 
Dim msg As New MessageItem(mailMess.ParseEmail(strMailContent, "From:"), _
                           mailMess.ParseEmail(strMailContent, "Subject:"), _
                           mailMess.ParseBody())
 
Messages.Add(msg)
 
Also replace ListBox1.Items.Clear() with Messages.Clear()
 
Now in your ListBox1_SelectedIndexChanged method you can set the textbox text with something like this:
 
RichTextBox1.Text = CType(ListBox1.SelectedItem, MessageItem).Body
GeneralRe: Listbox String to RichTextbox. Help Please! PinmemberGray_Ang3l24-Feb-13 13:29 
QuestionActive Directory Users OU Pinmemberdsj4122-Feb-13 8:14 
AnswerRe: Active Directory Users OU PinmvpDave Kreskowiak22-Feb-13 8:45 
GeneralRe: Active Directory Users OU Pinmemberdsj4124-Feb-13 11:20 
GeneralRe: Active Directory Users OU PinmvpDave Kreskowiak25-Feb-13 10:31 
GeneralRe: Active Directory Users OU Pinmemberdsj4126-Feb-13 0:14 
GeneralRe: Active Directory Users OU Pinmemberdsj415-Mar-13 1:43 
QuestionVolume Button in Text to Speech Convertor Pinmembersanju_na21-Feb-13 22:05 
QuestionHttpwebrequest + Socks5 Pinmembermathisderaltefuchs20-Feb-13 21:49 
AnswerRe: Httpwebrequest + Socks5 PinmvpRichard MacCutchan20-Feb-13 23:00 
QuestionHow can we read lengthy datas in Win Forms - more height than 780 in single page by scroll? PinmemberParamu197320-Feb-13 6:19 
AnswerRe: How can we read lengthy datas in Win Forms - more height than 780 in single page by scroll? PinmvpEddy Vluggen20-Feb-13 6:39 
GeneralRe: How can we read lengthy datas in Win Forms - more height than 780 in single page by scroll? PinmemberParamu197320-Feb-13 18:50 
GeneralRe: How can we read lengthy datas in Win Forms - more height than 780 in single page by scroll? PinmvpEddy Vluggen21-Feb-13 7:03 
QuestionMaximize MDIParent and MDIChild control Pinmemberkurja-kurdoh19-Feb-13 6:41 
AnswerRe: Maximize MDIParent and MDIChild control PinmemberSimon_Whale19-Feb-13 21:58 
QuestionDisable local accounts Pinmemberdouglas.s.johnson@l-3com.com19-Feb-13 5:57 

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

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


Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 1 Oct 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid