CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2012
    Posts
    16

    Unhappy 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

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: email validation

    So what is the question?
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: email validation

    the code is obviously half a porting from vb6, and the question is in the last part of it:
    Try
    What???
    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.

  4. #4
    Join Date
    Jan 2012
    Posts
    16

    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

  5. #5
    Join Date
    Jan 2012
    Posts
    16

    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.

  6. #6
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: email validation

    instead of remaining sit and wait, why don't you try a different query with google - like "verify email address"?

    http://www.labnol.org/software/verif...address/18220/

    http://www.webdigi.co.uk/blog/2009/h...ding-an-email/

    http://forums.asp.net/t/1545019.aspx/1
    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
  •  





Click Here to Expand Forum to Full Width

Featured