Results 1 to 6 of 6

Thread: How do I send email to more than 1 user

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Brisbane, Qld, Australia
    Posts
    78

    Question

    Hi,

    I want to be able to select in a listview an email address multiple time i.e select say 2 users out of the listview and then send those addresses to the default mail client. I know the command line for 1 is
    Shell "Start mailto:[email protected]" and that i have to use selecteditem.text. Here is the code I have used to try for multiple emails...

    Dim i As Integer, z As String
    Dim x As String, j As String
    Dim y As String, itmx As ListItem

    For i = 1 To LsvEmail.ListItems.Count
    j = LsvEmail.SelectedItem.Text
    x = j ????? not sure what to put here

    Next

    y = "start mailto:"
    z = y & x
    Shell z

    Therefore, what I want to end up with is this :
    so Z = "Start mailto:blah!email.com;[email protected];etc" and goes to the default email client. The user can then type away to send the email to the selected person/s. Any help would be greatly appreciated and thanx in advance

    Mike

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    Try this - assuming you have the Style Property of the Listbox set to "Checkbox"

    Code:
    Dim intDummy As Integer
    Dim strSendTo As String
    Dim strShellCmd as String
    
    strSendTo = ""
    For intDummy = 0 To List1.ListCount - 1
        If List1.Selected(intDummy) Then
            strSendTo = strSendTo + List1.List(intDummy) + ";"
        End If
    Next
    
    If strSendTo = "" Then
        MsgBox "You didn't pick anyone!"
        Exit Sub
    End If
    
    strSendTo = Left(strSendTo, Len(strSendTo) - 1)
    
    strShellCmd = "start mailto:" + strSendTo
    Shell strShellCmd
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    Ooh - I've just realised you said ListVIEW, not ListBOX - oops. It should be a similar type of function anyway.
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Brisbane, Qld, Australia
    Posts
    78
    yeah thanks Buzby for the code. Only one flaw. It only allows me the first selecteditem. How can i loop it so it will skip to the next selecteditem (multiselected items in the listview). Here is the adapted code from you (thanks):

    strSendTo = ""

    For i = 1 To LsvEmail.ListItems.Count - 1
    If LsvEmail.SelectedItem.Text = LsvEmail.ListItems(i).Text Then
    strSendTo = strSendTo + LsvEmail.ListItems(i).Text + ";"
    End If
    Next

    If strSendTo = "" Then
    MsgBox "Please reselect your Emailing Client as you have not yet selected one."
    Exit Sub
    End If

    strSendTo = Left(strSendTo, Len(strSendTo) - 1)

    ShellX = "start mailto:" + strSendTo
    Shell ShellX

    Mike

    [Edited by Spawny on 06-22-2000 at 08:18 AM]

  5. #5
    Lively Member
    Join Date
    May 1999
    Location
    Singapore
    Posts
    116
    try this, change it a bit, i may make some spelling errors some where

    strSendto=""

    for i=1 to lvwSend.listitems.count step 1
    if lvwSend.listitems(i).selected then strsendto=strsendto+lvwsend.listitems(i).text+";"

    next i

    If strSendTo = "" Then
    MsgBox "Please reselect your Emailing Client as you have not yet selected one."
    Exit Sub
    End If

    strSendTo = Left(strSendTo, Len(strSendTo) - 1)

    ShellX = "start mailto:" + strSendTo
    Shell ShellX
    YC Sim
    Teenage Programmer
    UIN 37903254



  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Brisbane, Qld, Australia
    Posts
    78

    Smile

    nah ycsim it doesn't work. Thanks anyway.

    your code suggested was :

    for i=1 to lvwSend.listitems.count step 1
    if lvwSend.listitems(i).selected then strsendto=strsendto+lvwsend.listitems(i).text+";"

    next i

    The problem is once the 'for' is set then it just loops from the next line until it ends. I am thinking there must be a type of loop to get the next part of 'lsvemail.selecteditem.text' <= the problem. How can i move to the next selecteditem?

    Thanks
    Mike

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