?
Solved

collect info from web into listbox

Posted on 2006-04-29
23
Medium Priority
?
206 Views
Last Modified: 2010-04-23
hello,
I have a button that when you click it, it goes to the mail
website and logs me in.
what I want to do is to collect the mail IDs and put them in my listbox
so If I see the link of the email like this

<a href="http://domain.com/mail.asp?accounts=MailID=0001">email 1</a>
<a href="http://domain.com/mail.asp?accounts=MailID=0002">email 2</a>

just collect the numers 0001 and 0002.. how can I do that?
so I can delete em!!
0
Comment
Question by:aplelois
23 Comments
 
LVL 5

Expert Comment

by:MageDribble
ID: 16586071
take a substring of the next 4 characters after the 3rd = sign.  you can use Instrrev to look for the last = sign and use that as the start location of your substring (+1 to get past the =) then take the next 4.
0
 

Author Comment

by:aplelois
ID: 16586104
im not an expert in VB.Net can you please show me how to do it ?
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16587219

Pass your string to this function

    Private Function RetrieveEmail(ByVal s As String) As String
        Dim sTemp As String = StrReverse(s)

        RetrieveEmail = StrReverse(sTemp.Substring(sTemp.IndexOf(">", 1), 6).Substring(2))
    End Function
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:HouseMusic
ID: 16587224
Do you have the list of links as a string variable or what?
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16587239
That only works where the numbers are always 4 digits
0
 

Author Comment

by:aplelois
ID: 16587264
it can be from 0 to 0123456789

<a href="http://domain.com/mail.asp?accounts=MailID=0">email 1</a>
<a href="http://domain.com/mail.asp?accounts=MailID=0123456789">email 2</a>

I only have a listbox and one button called start
0
 

Author Comment

by:aplelois
ID: 16587306
this is what im using to login

    Private Sub cmdLogin_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLogin.Click
        Dim URL As String
        On Error Resume Next

        URL = "http://domain.com"
        WebBrowser1.Navigate(New System.Uri(URL))

        'login section here

    End Sub
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16587313
How are you retrieving these URLs?

I think you are going to need to use Regex which I am not good at
0
 

Author Comment

by:aplelois
ID: 16587317
'login
 
       WebBrowser1.Document.DomDocument.Forms("f1").All("email").Value = "email@domain.com"
        WebBrowser1.Document.DomDocument.Forms("f1").All("passd").Value = "mypass"
        WebBrowser1.Document.DomDocument.Forms("theForm").submit()
0
 

Author Comment

by:aplelois
ID: 16587372
when I go to my email I see those anoying spam emails like this

knsdf mail
kjioljdn
lklkodf
etc...

so I have to select one by one and delete them so Instead I want
to collect their ID and let the program delete one by one instead of me
doing it!
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16587402
I am not still sure if your question is

1.  I want to get emailID from the string "<a href="http://domain.com/mail.asp?accounts=MailID=0001">email 1</a>"

or

2.  I want to extract the string "<a href="http://domain.com/mail.asp?accounts=MailID=0001">email 1</a>" from the website
0
 

Author Comment

by:aplelois
ID: 16587435
no I want to extract this last number 0 or 0001
so then I just make something to go to
http://domain.com/delete.asp?mail=ID=0001
and delete em all
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16587485
Ok got you now, will try a solution in a minute
0
 
LVL 12

Accepted Solution

by:
gbzhhu earned 2000 total points
ID: 16588053
Ok here you go

    Private Function RetrieveEmail(ByVal s As String) As String
        Dim regex As Regex = New Regex("(?<Digits>\d+)")
        Dim match As Match = regex.Match(s)

        MessageBox.Show(match.ToString())
        RetrieveEmail = match.ToString()
    End Function

Try that
0
 

Author Comment

by:aplelois
ID: 16588207
this is not working

    Private Sub cmdCollect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCollect.Click
        Call RetrieveEmail()
    End Sub

    Private Function RetrieveEmail(ByVal s As String) As String
        Dim regex As Regex = New Regex("(?<Digits>\d+)")
        Dim match As Match = regex.Match(s)

        MessageBox.Show(match.ToString())
        RetrieveEmail = match.ToString()
    End Function
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16588242
It won't work because the RetrieveEmail function expects a trsing (URL) passed to it and it will return the email ID if found

Change

Call RetrieveEmail()

to

Call RetrieveEmail(sURL)  where sURL is the URL containing the emailID

0
 

Author Comment

by:aplelois
ID: 16588405
no thats not what im looking for!
0
 

Author Comment

by:aplelois
ID: 16588701
look this is what I have
http://img81.imageshack.us/img81/5885/frsd3ba.jpg

I want to collect all the IDs in the listbox that you see there in the left..
so whem Im at the page I click collect and it will scan the URLs and
show up all the IDs
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16594532
Are the URLs on the page?  Is this a web project or a windows project?  We need to figure out how to get the urls it is then easy to extract the email and fill the listbox
0
 

Author Comment

by:aplelois
ID: 16595227
windows project, yes the URLs are on the page!!!
0
 
LVL 27

Expert Comment

by:Dabas
ID: 16603267
Hi aplelois,
Can you post a jpg with the program in run mode, instead of design mode?
Do the URL's appear in ListBox1, or on the other control to the right?

Dabas
0
 

Author Comment

by:aplelois
ID: 16606729
the websites appear in the right
and I want the IDs to appear in the left
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16609075
I provided a solution to extract emaiIDs given a URL.  

This question could be regarded as 2 questions

1.  How do i extract URLs in a WebBrowser control
2.  How do i extract emailIDs from these URLs

To get answers to number 1 you need to ask how to extract URLs from WebBrowser control (which I don't know how).  Ideally in another question to attract new experts in that field
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question