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

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

问题描述

大家好,

请帮助我,我得到这个例外。



格式例外:

hi all,
please help me ia m getting this exception.

Format Exception:

The specified string is not in the form required for an e-mail address.



在我的项目中,当我安排培训时,我一次给两个教员姓名分开通过逗号然后我得到这个例外。我正在给出正确的电子邮件地址格式,但我正面临。



请anuone helpppp me。


in my project when i am scheduling trainings the i am giving tow faculty names at a time separated by comma then i am getting this exception.i am giving the correct format of email addresses but i am facing.

please anuone helpppp me.

推荐答案

没有相关的代码片段,我们必须猜测...

你不能用逗号分隔电子邮件地址 - 如果你想发送向不同的人发送相同的消息,然后

1)发送给其中一个和CC(或BCC)另一个

2)发送消息两次。

3)对两个不同的新MailAddress实例使用MailMessage.To.Add方法。
Without the relevant code fragments, we have to make guesses...
You can''t separate email addresses with a comma - if you want to send the same message to different people, then
1) Send it to one of them and CC (or BCC) the other
2) Send the message twice.
3) Use the MailMessage.To.Add method for two different new MailAddress instances.


我在向多个电子邮件地址发送电子邮件时遇到此问题。我使用了分隔符;分开电子邮件地址。由于outlook使用相同格式的分隔多个电子邮件地址。但它没有奏效。而不是使用;我们应该使用,来分隔多个电子邮件。这对我有用。

更多详情:

访问:http://kopila.com.np/
I faced this problem while sending email to multiple email address. I used the delimiter ";" to separate the email addresses. As outlook uses the same format of separating multiple email addresses. But it didnot worked.Instead of using the ";" we should use the "," for separating the multiple emails. And this worked for me.
For more details :
visit: http://kopila.com.np/


你可以使用逗号分隔列表添加多个地址。例如,以下内容应该可以正常工作:

You can add several addresses using a comma separated list. For example the following should work fine:
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
mm.To.Add("aaa@bbb.ccc, ddd@eee.fff");



但是如果有一个无效的地址,你会得到一个例外。另请注意,例外情况不一定来自收件人地址,也可能来自发件人地址。



所以没有看到实际代码的最佳选择是通过代码调试,看看出了什么问题。



另请注意,OriginalGriff写的是,最好一次添加一个收件人。当使用适当的try..catch块在循环中完成时,您可以决定遇到无效地址时要执行的操作。如果你把它们全部加在一起,那么就很难找到有问题的地址并继续使用其他地址。


However if there''s even one invalid address, you''ll get an exception. Also note that the exception isn''t necessarily coming from the recipient address, it could also come from the sender address.

So without seeing the actual code the best option is to debug through the code and see what''s going wrong.

Also note that what OriginalGriff wrote, it would be best to add a single recipient at a time. When done in a loop using a proper try..catch block you can decide what to do when an invalid address is encountered. If you add them all together, it''ll be harder to catch the problematic address and to continue with other addresses if that''s needed.


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

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