{"action":"opened","issue":{"url":"https://api.github.com/repos/sendgrid/sendgrid-csharp/issues/338","repository_url":"https://api.github.com/repos/sendgrid/sendgrid-csharp","labels_url":"https://api.github.com/repos/sendgrid/sendgrid-csharp/issues/338/labels{/name}","comments_url":"https://api.github.com/repos/sendgrid/sendgrid-csharp/issues/338/comments","events_url":"https://api.github.com/repos/sendgrid/sendgrid-csharp/issues/338/events","html_url":"https://github.com/sendgrid/sendgrid-csharp/issues/338","id":180415906,"number":338,"title":"SendGrid library email name parsing behavior differs from System.Net.Mail","user":{"login":"snumpy","id":21311764,"avatar_url":"https://avatars.githubusercontent.com/u/21311764?v=3","gravatar_id":"","url":"https://api.github.com/users/snumpy","html_url":"https://github.com/snumpy","followers_url":"https://api.github.com/users/snumpy/followers","following_url":"https://api.github.com/users/snumpy/following{/other_user}","gists_url":"https://api.github.com/users/snumpy/gists{/gist_id}","starred_url":"https://api.github.com/users/snumpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snumpy/subscriptions","organizations_url":"https://api.github.com/users/snumpy/orgs","repos_url":"https://api.github.com/users/snumpy/repos","events_url":"https://api.github.com/users/snumpy/events{/privacy}","received_events_url":"https://api.github.com/users/snumpy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-30T22:33:17Z","updated_at":"2016-09-30T22:33:17Z","closed_at":null,"body":"#### Issue Summary\r\n\r\nSystem.Net.Mail.MailAddress intelligently surrounds DisplayName in quotes if and only if they are not included by the user.\r\nSendGrid.Helpers.Mail.Mail fails to surround Name in quotes if they are not included by user, causing an otherwise valid display name corrupt the entire address.\r\n\r\nI would expect the two libraries to have similar behavior.\r\n\r\n#### Steps to Reproduce\r\n\r\n(see results in comments)\r\n\r\n\t\tprivate void DotNetExample(string toName)\r\n\t\t{\r\n\t\t\t// using System.Net.Mail;\r\n\t\t\tMailMessage message = new MailMessage();\r\n\t\t\tmessage.From = new MailAddress(\"from@example.com\", \"From\");\r\n\t\t\tmessage.To.Add(new MailAddress(\"user@example.com\", toName));\r\n\t\t\tmessage.Subject = \"Example\";\r\n\t\t\tmessage.Body = \"Example body\";\r\n\t\t\tmessage.IsBodyHtml = false;\r\n\r\n\t\t\tusing (SmtpClient client = new SmtpClient())\r\n\t\t\t{\r\n\t\t\t\tclient.Send(message);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate async Task SendGridExample(string toName)\r\n\t\t{\r\n\t\t\t// using SendGrid.Helpers\r\n\t\t\t// using SendGrid.Helpers.Mail;\r\n\t\t\tSendGridAPIClient sg = new SendGridAPIClient(ConfigurationManager.AppSettings[\"sgApiKey\"]);\r\n\r\n\t\t\tMail mail = new Mail();\r\n\t\t\tmail.From = new Email(\"from@example.com\", \"From\");\r\n\t\t\tPersonalization personalization = new Personalization();\r\n\t\t\tpersonalization.AddTo(new Email(\"user@example.com\", toName));\r\n\t\t\tmail.AddPersonalization(personalization);\r\n\t\t\tmail.Subject = \"Example\";\r\n\t\t\tmail.AddContent(new SendGrid.Helpers.Mail.Content(\"text/plain\", \"Example body\"));\r\n\t\t\t\r\n\t\t\tdynamic response = await sg.client.mail.send.post(requestBody: mail.Get());\r\n\t\t}\r\n\r\n\t\tprivate void EmailTester()\r\n\t\t{\r\n\t\t\tstring toName = \"\\\"Last, First\\\"\";\r\n\t\t\tDotNetExample(toName); // success (From: \"Last, First\" <user@example.com>)\r\n\t\t\tSendGridExample(toName); // success (From: \"Last, First\" <user@example.com>)\r\n\r\n\t\t\ttoName = \"Last, First\";\r\n\t\t\tDotNetExample(toName); // success (From: \"Last, First\" <user@example.com>)\r\n\t\t\tSendGridExample(toName); // Invalid email \"last\"\r\n\t\t}\r\n\r\n\r\n#### Technical details:\r\n\r\n* sendgrid-csharp Version: master (v8.0.3)\r\n* .NET Version: 4.6"}}
{"actor":{"display_login":"snumpy"}}