Closed
Description
Issue Summary
Similar to: sendgrid/sendgrid-python#348
Where the user can submit email addresses as:
example@example.com
or
example example <example@example.com>
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
brandon93s commentedon Oct 22, 2017
Looks like there is already an implementation in
MailHelper
that is available to consumers, but not called automatically anywhere.The constructor for EmailAddress could be updated to call this method, adding support:
Thoughts?
Niladri24dutta commentedon Apr 4, 2018
@thinkingserious I can submit a PR with the change suggested above regarding
MailHelper.StringToEmailAddress
. Let me know if it's fine.thinkingserious commentedon Apr 5, 2018
That would be great, thanks @Niladri24dutta!
Niladri24dutta commentedon Apr 16, 2018
@thinkingserious just an observation regarding the above approach ,
MailHelper.StringToEmailAddress
calls theEmailAddress
class constructor internally . If we use theMailHelper.StringToEmailAddress
method in the constructor ofEmailAddress
class then it may create 2 issues -EmailAddress
class will be called infinite times if thename
is null and the email address is matched with RFC2822 format.To overcome this have created a new overload of the
EmailAddress
class constructor which accepts a email address and a boolean flag to denote whether email address is in RFC2822 format like belowpublic EmailAddress(string email, bool isRFC2822Address)
Let me know your view on this before I proceed.
Here is my working branch
https://github.com/Niladri24dutta/sendgrid-csharp/tree/RFC822CompliantEmailSupport
thinkingserious commentedon Apr 16, 2018
How about factoring out this part:
Then you could just call the factored method internally without the cyclic dependency.
With Best Regards,
Elmer
Niladri24dutta commentedon Apr 17, 2018
@thinkingserious Then,do we need to create a new helper method in
MailHelper
class to include the above code you mentioned or should we refactor the existingStringToEmailAddress
method. Because I can see when the email id is not matched then also theEmailAddress
class constructor is called as seen below -https://github.com/sendgrid/sendgrid-csharp/blob/master/src/SendGrid/Helpers/Mail/MailHelper.cs#L139
However,we can change the return type of the
StringToEmailAddress
to return aDictionary<string>
which can contain theemail
andname
as key value pair.thinkingserious commentedon Apr 18, 2018
I think you can encapsulate that check into a utility function, for example, maybe
isRfc2822Email(email)
. We should try to not changeStringToEmailAddress
's function signature to avoid any breakage. Unless you want to overload the function.thinkingserious commentedon Mar 10, 2021
Since there has been no activity on this issue since March 1, 2020, we are closing this issue. Please feel free to reopen or create a new issue if you still require assistance. Thank you!