Results 1 to 3 of 3

Thread: [2005] E-mailing Contents of Listview

  1. #1

    Thread Starter
    Hyperactive Member Jonny1409's Avatar
    Join Date
    Mar 2005
    Posts
    308

    [2005] E-mailing Contents of Listview

    Hello,

    I wonder if anyone can help me please ?

    I have a listview which contains several rows of data relating to several employees.
    I'd like to know if it is possible to e-mail each employee the rows relating to them.

    So for example :

    Row 1 = Joe Bloggs / ABC / DEF / GHI
    Row 2 = Fred Bloggs / 123 / 456 / 789
    Row 3 = Joe Bloggs / XYZ / XYZ / XYZ

    Joe would get an e-mail containing 2 rows and Fred would get an e-mail containing 1 row.

    Is this possible ?
    If so, where would I begin ?

    Thanks.

  2. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: [2005] E-mailing Contents of Listview

    One way to do it would be to use a Dictionary perhaps. Then when sending the email output the value into the body of the email text and send. Loop through each person to send a new email. This might give you a start:
    vb Code:
    1. Dim myRecords As New Dictionary(Of String, List(Of String))
    2.  
    3. If Not myRecords.ContainsKey("Joe Bloggs") Then      'If Name doesn't exist then add it to dictionary Key
    4.     myRecords.Add("Joe Bloggs", New List(Of String))   'Add name
    5.     myRecords("Joe Bloggs").Add("ABC / DEF / GHI")       'Add value
    6. End If
    7.  
    8. If myRecords.ContainsKey("Joe Bloggs") Then          'If name already exists then simply
    9.       myRecords("Joe Bloggs").Add("XYZ / XYZ / XYZ")     'add new value
    10. End If
    11.  
    12. 'Set up your email and in the body text you would
    13. 'Loop through the contents per Key (person you send it to)
    14. 'output the content for that particular key into body of email
    15. For Each itm As KeyValuePair(Of String, List(Of String)) In myRecords
    16.       For i As Integer = 0 To itm.Value.Count - 1
    17.           MessageBox.Show(itm.Key & " " & itm.Value.Item(i))   'Show name and any values associated in collection
    18.       Next
    19. Next

    edit I should add that this would assume you loop through your ListView and pass each of the values in the columns into the values above so you wouldn't obviously need to literally pass the value Joe Bloggs etc...
    Last edited by stimbo; Oct 30th, 2007 at 06:07 AM.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  3. #3

    Thread Starter
    Hyperactive Member Jonny1409's Avatar
    Join Date
    Mar 2005
    Posts
    308

    Re: [2005] E-mailing Contents of Listview

    Thanks Stimbo - I'll have a look into that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width