|
-
January 30th, 2012, 08:40 PM
#1
email validation
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.
There is a code:
Code:
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
-
January 30th, 2012, 09:19 PM
#2
Re: email validation
Always use [code][/code] tags when posting code.
-
January 31st, 2012, 12:03 AM
#3
Re: email validation
the code is obviously half a porting from vb6, and the question is in the last part of it:
in net since 2.0 we have the permission class for that.THis is a translation of C# code from
http://msdn.microsoft.com/en-us/libr...ccess.aspx#Y69
Code:
privatec function CreateConnectPermission() As SmtpPermission
dim connectAccess as new SmtpPermission(SmtpAccess.Connect)
if connectAccess.Access then
Debug.writeLine("Accessed")
end if
return connectAccess
end function
Last edited by Cimperiali; January 31st, 2012 at 12:19 AM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
January 31st, 2012, 04:32 AM
#4
Re: email validation
This permission class looks good,but is not working.I modify it,but still not working.
Private Function CreateConnectPermission() As SmtpPermission
Dim connectAccess As New SmtpPermission(SmtpAccess.Connect)
If
connectAccess.Access = True
MsgBox("Successfully logged", MsgBoxStyle.Information, "Report")
Else
MsgBox("Unsuccessfully logged", MsgBoxStyle.Information, "Report")
End If
End Function
-
February 6th, 2012, 01:31 PM
#5
Re: email validation
I was trying to resolve as you say but nothing.
I'am waiting for a right person to resolve problem.
Tnx anyway.
-
February 6th, 2012, 03:12 PM
#6
Re: email validation
Last edited by Cimperiali; February 8th, 2012 at 04:18 AM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
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
|