指定的字符串不是电子邮件地址所需的形式 [英] The specified string is not in the form required for an e-mail address

查看:296
本文介绍了指定的字符串不是电子邮件地址所需的形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

指定的字符串不是电子邮件地址所需的格式。
说明:在执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误的更多信息及其在代码中的位置。

The specified string is not in the form required for an e-mail address. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:System.FormatException:指定的字符串不是所需的形式一个电子邮件地址。

Exception Details: System.FormatException: The specified string is not in the form required for an e-mail address.

源错误:

行150:msg .From = new MailAddress(khaledaparveen11@gmail.com);

第151行:

第152行:msg.To.Add(新的MailAddress(txtEmail.Text));

第153行:

行154:msg.Subject =这是一个测试电子邮件主题;

推荐答案

msg.To.Add(new MailAddress("txtEmail.Text"));

是问题。 txtEmail.Text不是电子邮件地址。如果这是一个电子邮件列表的文本文件,您将需要打开它并阅读并逐个传递。

is the problem. txtEmail.Text is not an e-mail address. If that's a text file that's a list of e-mails, you're going to need to open it and read it and pass them in one by one.

如果是指的是一个文本框,把它引起来。像这样:

If it's referring to a textbox, take the quotes around it off. Like this:

msg.To.Add(new MailAddress(txtEmail.Text));

这篇关于指定的字符串不是电子邮件地址所需的形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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