System.net.mail不接受有效的电子邮件地址 [英] System.net.mail not accepting valid email address

查看:163
本文介绍了System.net.mail不接受有效的电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。 VB Net 2008

我使用System.Net.mail(System.Net版本3.5.0.0)发送电子邮件。



我们有一个完全有效的电子邮件地址,格式名称。@ outlook.com

(注意@之前的时间段)但是当使用

mymailmessage.To.Add添加电子邮件地址时(name。@ outlook.com)我们收到以下错误:



指定的字符串不是电子邮件地址所需的格式



因此我们无法通过代码向该客户发送电子邮件。



关于如何使用的任何想法解决这个问题?



我尝试过:



我们已经通过邮件客户端(outlook,thunderbird)手动测试了电子邮件地址,客户端收到了完美的电子邮件。

解决方案





您收到例外的原因是因为电子邮件地址格式无效。



有看看:

电子邮件地址 - 维基百科,免费的百科全书 [ ^ ]



本地部分:

字符。 (点,句号,句号),ASCII 46,,前提是它不是第一个或最后一个字符,并且还提供它不会连续出现



我不确定你的邮件客户是如何发送到这个地址的。



...希望它有所帮助。


这个bug似乎已经在框架的4.0和4.6版本之间修复了。以下代码在.NET 3.5中失败,但在我的机器上按预期工作在4.6:

  var  address =  new  MailAddress(  name。@ outlook.com ); 



如果您需要支持这种类型的地址,似乎您唯一的选择是升级到更新版本的.NET Framework


Hi. VB Net 2008
Im using System.Net.mail (version 3.5.0.0 of System.Net) to send emails.

We have a perfectly valid email address in the format name.@outlook.com
(Note the period before the @) but when adding the email address using
mymailmessage.To.Add("name.@outlook.com") we get the following error :

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

and therefore we are unable to send an email to this client in code.

Any ideas on how to resolve this issue?

What I have tried:

We have tested the email address manually via mail clients (outlook, thunderbird) and the client receives emails perfectly.

解决方案

Hi,

The reason you are receiving an exception is because the email address format is NOT valid.

Have a look at:
Email address - Wikipedia, the free encyclopedia[^]

Local part:
Character . (dot, period, full stop), ASCII 46, provided that it is not the first or last character, and provided also that it does not appear consecutively

I'm not sure how your mail clients are able to send to this address.

... hope it helps.


This bug seems to have been fixed somewhere between versions 4.0 and 4.6 of the framework. The following code fails in .NET 3.5, but works as expected in 4.6 on my machine:

var address = new MailAddress("name.@outlook.com");


If you need to support this type of address, it seems your only option is to upgrade to a more recent version of the .NET Framework.


这篇关于System.net.mail不接受有效的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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