collect info from web into listbox

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!!
apleloisAsked:
Who is Participating?
 
gbzhhuCommented:
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
 
MageDribbleCommented:
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
 
apleloisAuthor Commented:
im not an expert in VB.Net can you please show me how to do it ?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
gbzhhuCommented:

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
 
HouseMusicCommented:
Do you have the list of links as a string variable or what?
0
 
gbzhhuCommented:
That only works where the numbers are always 4 digits
0
 
apleloisAuthor Commented:
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
 
apleloisAuthor Commented:
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
 
gbzhhuCommented:
How are you retrieving these URLs?

I think you are going to need to use Regex which I am not good at
0
 
apleloisAuthor Commented:
'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
 
apleloisAuthor Commented:
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
 
gbzhhuCommented:
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
 
apleloisAuthor Commented:
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
 
gbzhhuCommented:
Ok got you now, will try a solution in a minute
0
 
apleloisAuthor Commented:
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
 
gbzhhuCommented:
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
 
apleloisAuthor Commented:
no thats not what im looking for!
0
 
apleloisAuthor Commented:
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
 
gbzhhuCommented:
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
 
apleloisAuthor Commented:
windows project, yes the URLs are on the page!!!
0
 
DabasCommented:
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
 
apleloisAuthor Commented:
the websites appear in the right
and I want the IDs to appear in the left
0
 
gbzhhuCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.