电子邮件验证问题 [英] email validation problem

查看:86
本文介绍了电子邮件验证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想问一个想解决的人.
我制作了一个登录"应用程序,用于检查带有用户名和密码作为输入的电子邮件地址.作为输出,它将向我显示包含内容您的电子邮件和密码正确!"的msgbox.是否.

问题是在代码末尾.
请尝试帮助我. . .

有一个代码:

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:

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

推荐答案

这是一个巨大的毫无意义的代码转储.整个网络上都有正则表达式,用于检查电子邮件地址是否为有效格式.除非您获取他们的邮件服务器信息并尝试发送电子邮件,否则您将无法分辨出电子邮件地址是否真实,这就是网站向您发送包含确认链接的电子邮件的原因(将GUID放在网址是根据该帐户存储的).
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 ).


这篇关于电子邮件验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆