Email Generator

Posts 1–15 of 15 · Page 1 of 1
Email Generator
Ok. I am almost done. Yay.
Thanks too many of you. you know who u are.

ok.
i got some last questions to ask.

I am trying to make a captcha viewer in my vb.
so there is a textbox to write the captcha manually and a picturebox that has the captcha inside.

how do i make that?
Here is the source code but i dont know how to make it work.

Code:
Dim num2 As Integer
    Try 
        Dim num3 As Integer
    Label_0000:
        ProjectData.ClearProjectError
        Dim num As Integer = -2
    Label_0008:
        num3 = 2
        Me.CaptchaPic.ImageLocation = Me.browser.Document.GetElementById("cimg").GetAttribute("src")
    Label_0034:
        num3 = 3
        If Not Me.check Then
            goto Label_0060
        End If
    Label_003E:
        num3 = 4
        Me.browser.Document.GetElementById("tos_agreed_o_0").InvokeMember("click")
    Label_0060:
        num3 = 6
        Me.tmrCaptcha.Enabled = False
    Label_006E:
        num3 = 7
        Me.check = False
        goto Label_00EE
    Label_0079:
        num2 = 0
        Select Case (num2 + 1)
            Case 1
                goto Label_0000
            Case 2
                goto Label_0008
            Case 3
                goto Label_0034
            Case 4
                goto Label_003E
            Case 5, 6
                goto Label_0060
            Case 7
                goto Label_006E
            Case 8
                goto Label_00EE
            Case Else
                goto Label_00E3
        End Select
    Label_00A9:
        num2 = num3
        Select Case IIf((num > -2), num, 1)
            Case 0
                goto Label_00E3
            Case 1
                goto Label_0079
        End Select
    Catch obj1 As Object When (?)
        ProjectData.SetProjectError(DirectCast(obj1, Exception))
        goto Label_00A9
    End Try
Label_00E3:
    Throw ProjectData.CreateProjectError(-2146828237)
Label_00EE:
    If (num2 <> 0) Then
        ProjectData.ClearProjectError
    End If
End Sub
Code:
Dim captcha1 As HtmlElement
        captcha1 = WebBrowser1.Document.GetElementById("Captcha ID Here")
        Dim path As String = captcha1.FirstChild.GetAttribute("src")
        My.Computer.Network.DownloadFile(path, "C:\Captcha1.jpg") ' or application path
You might display this in a picturebox.

Now you do the following:

You add a textbox.

Code:
Webbrowser1.document.getelementbyid("id for textbox where to enter captcha").innertext = textbox1.text
i wouldn't recommend the c drive, in vista and win 7 you need admin to put files in there.
@blubb this is my understanding of your code. tel me if im wrong.
so basically it finds the captcha picture and saves it to your c drive.
then you make a picturebox and it find the captcha picture that was downloaded and displays it.

right?
Why doesn't anyone search, this section is getting out of hand and out of control, this question has been asked in 2 seperate other posts in 2 days and I answered them , Please Search, if you can't find the answer post it, and I know this is off topic we we don't need 3 or 4 pre releases either


On Topic
Code:
Picturebox1.ImageLocation = "https://ab.login.yahoo.com/img/vMH30.JZFelpq53KSjMRC7hVgxvJQImT7pygFryAvdAIm_llEt6U17UmgYs0nufSo8n8Imp6WsyCDUNHh4vz.pSetd5izNI1GNsm2w--.jpg"
Assuming the Location doesn't change
Code:
            Dim web1 As WebClient = New WebClient
            PictureBox1.Image = (New Bitmap(New MemoryStream(web1.DownloadData("captcha url here"))))
Don't forget to import these namespaces:
System.Net
System.drawing
System.IO
@ Lolland, Again like mine, only works if the url doesn't change, the following is the "better alternative"


If you dont know the location of the image or if the name is generated with javascript (which is happening alot now)

Use:

Code:
Dim captcha1 As HtmlElement
        captcha1 = WebBrowser1.Document.GetElementById("cimg")
        Dim path As String = captcha1.FirstChild.GetAttribute("src")
        My.Computer.Network.DownloadFile(path, "C:\Captcha1.jpg") ' or application path
That will always work with yahoo, if your using a different email like gmail, just change the ID to the proper ID

Note: The other good thing about the above code is you only need to know the ID it will grab the src for you
Here's how I found the captcha url with my Nexon Passport Generator:
I checked out the source of Nexon Passport Sign-Up and found the captcha part:

[php]<td><img id="captchaFS_Image" src="FormShieldHttpHandler.aspx?__formShieldID=cap tchaFS&amp;generate=image&amp;properties=4CDE5D781 2F773A3BE5BB56FE97A35F22F5A9E66CAA30BB465BE4FFF7EC 07552869C25A07B41475FC613F372B60C24D51FCB935ABDC7A 1EE268671F916EE95E5" alt="Protected by FormShield" title="Protected by FormShield" height="49" width="240" /></td>
[/php]

Notice how the url of the image is a series of random characters.

I needed to extract the URL of the image, simple enough, huh?

Now using the .length and .indexof statements I was able to find the exact url of the captcha, save it as a string variable, and then transfer the picture onto a picturebox.
Agreed, In Chrome you can right click and view element which will load the source to the specific element, however , I am trying to simplify the code , and Fact is some companies use random jpg names that are generated via javascript, if yahoo is one of them then a static url won't work,

It has to do with professionalism (to an extent)

Using tables in HTML or anyform of web design works great, however because of some known issues it is bad etiquette to do so , same applies here, the code provided initially by myself and lolland and others will work, on a per src=proper Url basis, but what if javascript generates new names (which I am pretty sure they do) then your code will work once , but not all the time, it is better to get into the habit now on how to grab the src programatically to avoid firther issues in furture (or current) coding / design
HUR DUR:
Code:
Public Class Form1
    Dim finalresult As String = String.Empty
    Private Sub FindValidationCode()
        WebBrowser1.Navigate("https://edit.yahoo.com/registration?.src=fpctx&.intl=ca&.done=http://ca.yahoo.com/")
        Dim web2 As String = WebBrowser1.Document.Body.InnerHtml
        Dim web1 As String = web2
        Dim startcode As String = "/img/"
        Dim start As Integer = web1.IndexOf(startcode)
        Dim end1 As Integer = web1.IndexOf("""")
        Dim result1 As String = web1.Remove(0, start + startcode.Length)
        Dim result2 As String = result1.Remove(end1, result1.Length - end1)
        finalresult = "https://ab.login.yahoo.com/img/" + result2 + "--.jpg"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If WebBrowser1.StatusText = "Done" Then
            FindValidationCode()
            Picturebox1.ImageLocation = finalresult

        Else
            MsgBox("Wait for the Webbrowser to load")
        End If
    End Sub
End Class
Only thing is that Yahoo disallows you from downloading their captchas, but you got the idea.
Not Comparing, But it's a no brainer, The code I use Requires no Downloading, and it doesn't matter what the URL is,
Even using your method it doesn't work.
You sure?

:Goes and tests:

Edit: Almost got it working , One sec.

I got it to work, I will write my long solution here. bare with me

Edit 2 : Think Outside the box for a solution
Posts 1–15 of 15 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?