Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,I have a question for anyone who knows to resolve.
I making an "sign in" application for checking email address with username and password as input.As output it will show me msgbox with content "Your email and password are correct!" or Not.

Problem is at the end of the code.
Please try to help me. . .

There is a code:

VB
Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim sSelectedSMTPServer As String = ""
Dim iSelectedSMTPPort As Integer

'Check wich email account is selected and provide correct smtp address / port.
Select Case True
Case CheckBox1.Checked
sSelectedSMTPServer = "smtp.gmail.com"
iSelectedSMTPPort = 587
Case CheckBox2.Checked
sSelectedSMTPServer = "smtp.live.com"
iSelectedSMTPPort = 587
Case CheckBox3.Checked
sSelectedSMTPServer = "smtp.mail.yahoo.com"
iSelectedSMTPPort = 465
Case Else
'If no account is selected you will get a message and the program will not attempt to send the email.
MsgBox("Please choose your email service.", vbInformation)
End Select
'For multiple selection
If CheckBox1.Checked And CheckBox2.Checked Then
MsgBox("You must select only one email service.", vbInformation)
ElseIf CheckBox1.Checked And CheckBox3.Checked Then
MsgBox("You must select only one email service.", vbInformation)
ElseIf CheckBox2.Checked And CheckBox3.Checked Then
MsgBox("You must select only one email service.", vbInformation)
ElseIf CheckBox1.Checked And CheckBox2.Checked And CheckBox3.Checked Then
MsgBox("You must select only one email service.", vbInformation)
End If

Exit Sub

Dim SMTP As New SmtpClient
'SSL enabled for outgoing mail.
SMTP.EnableSsl = True
'Get login credentials.
SMTP.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
'SMTP Port that will be used.
SMTP.Port = iSelectedSMTPPort

Try
'What???
MsgBox("Successfully logged", MsgBoxStyle.Information, "Report")
Me.Close()
Catch ex As Exception
MsgBox("Unsuccessfully logged", MsgBoxStyle.Exclamation, "Report")
End Try
End Sub
Posted
Updated 6-Feb-12 7:57am
v2
Comments
Sander Rossel 6-Feb-12 14:01pm    
How should we know what you need to do? My guess is you want to login using a gmail, live or yahoo account. I guess you should check their API's and call some method there that checks if a given username and password match. If not, I have no idea what it is you're trying to achieve...
Herman<T>.Instance 6-Feb-12 14:01pm    
You print:
"Successfully logged"
Or
"Unsuccessfully logged"
So you never have a messagebox with output "Your email and password are correct!"

Can you tell what you see when you debugged the code?
blueye89 6-Feb-12 14:17pm    
I will input username and password into two textboxes and when I click on button "Check It",it will test does password is match with real password for given email.If password is match it will show me a message "Successfully match",if it is not "Unsuccessfully match".
Herman<T>.Instance 6-Feb-12 14:28pm    
what is the Exit Sub doing in the middle of the code?
blueye89 6-Feb-12 14:35pm    
It's my mistake,sorry.But if remove that "Exit sub" it still not working.Problem is in:
Try
I don't know what to input here.

Catch ex As Exception
End try

1 solution

This is a huge pointless code dump. There are regular expressions all over the web to check if an email address is in a valid format. Unless you take their mail server info and try to send an email with it, you cannot tell if an email address is genuine, that's why websites send you an email with a link to confirm ( by putting a GUID on the URL which was stored against this account ).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900