|
-
Jun 20th, 2000, 07:38 PM
#1
Thread Starter
Lively Member
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
-
Jun 20th, 2000, 08:20 PM
#2
Frenzied Member
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."
-
Jun 20th, 2000, 08:29 PM
#3
Frenzied Member
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."
-
Jun 21st, 2000, 06:48 PM
#4
Thread Starter
Lively Member
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]
-
Jun 23rd, 2000, 01:45 PM
#5
Lively Member
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
-
Jun 23rd, 2000, 02:18 PM
#6
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|