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

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

问题描述

指定的字符串不是一个电子邮件地址所要求的形式。
说明:执行当前Web请求的执行过程中发生未处理的异常。请检查堆栈跟踪有关该错误的详细信息以及它起源于code。

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

源错误:

150线:msg.From =新的MailAddress(khaledaparveen11@gmail.com);

151线:

152线:msg.To.Add(新MailAddress(txtEmail.Text));

153线:

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


解决方案

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

就是问题所在。 txtEmail.Text不是一个电子邮件地址。如果这是一个文本文件,该文件的电子邮件列表,你会需要一个一个打开它,阅读它,并通过他们。

如果它指的是一个文本框,拿周围的报价了。像这样的:


  

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


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.

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

Source Error:

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

Line 151:

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

Line 153:

Line 154: msg.Subject = "This is a test Email subject";

解决方案

msg.To.Add(new MailAddress("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天全站免登陆