我的项目名称中有一个表单"电子邮件.cs"作为"电子邮件客户端"
在这种形式中,我有一个链接标签控件名称作为"验证电子邮件地址"
我设计了一个网页名称为"验证.aspx"。在此网页中,我有一个文本框控件
和一个按钮控制。当我在文本框中输入任何地址并单击按钮时
立即检查输入到文本框中的电子邮件地址是否实际存在或
不在"GMAIL服务器"上。
所以我的问题是,如何将这个网页添加到我的Windows窗体项目中
在询问SO之前,您需要为此付出一些努力,请尝试在线搜索并查看示例(例如此处)。您只需向表单添加WebControl
即可。
您可以使用Regex
来验证电子邮件地址或尝试以下操作。
//NOTE: This code will not catch double periods, extra spaces. For more precision, stick to Regex.
public bool IsEmailValid(string emailAddress)
{
try
{
MailAddress m = new MailAddress(emailAddress);
return true;
}
catch (FormatException)
{
return false;
}
}
验证电子邮件地址Regex
方法:
String email = "test@gmail.com";
Regex regex = new Regex(@"^[w!#$%&'*+-/=?^_`{|}~]+(.[w!#$%&'*+-/=?^_`{|}~]+)*"
+ "@"
+ @"((([-w]+.)+[a-zA-Z]{2,4})|(([0-9]{1,3}.){3}[0-9]{1,3}))$";);
Match match = regex.Match(email);
if (match.Success)
//Email is has the right format.
else
//Email doesn't have the correct format.
但是,如果您的目标是与Gmail进行通信,则需要使用:
GMAIL API - https://developers.google.com/gmail/