Esempio n. 1
0
        private void AddRecipients(Mail mail, BsonDocument headers)
        {
            try
            {
                var to   = headers.GetValue("To", null)?.AsString;
                var xTo  = headers.GetValue("X-To", null)?.AsString;
                var cc   = headers.GetValue("Cc", null)?.AsString;
                var xCc  = headers.GetValue("X-cc", null)?.AsString;
                var bcc  = headers.GetValue("Bcc", null)?.AsString;
                var xBcc = headers.GetValue("X-bcc", null)?.AsString;

                var parsedRecipients = RecipientParser.ParseRecipients(to, xTo, cc, xCc, bcc, xBcc);

                foreach (var parsedRecipient in parsedRecipients)
                {
                    mail.Recipients.Add(new Recipient
                    {
                        EmailAccountId = EmailAccountProvider.GetEmailAccount(parsedRecipient.EmailAddress).Id,
                        Name           = parsedRecipient.Name,
                        Type           = parsedRecipient.RecipientType
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occurred while adding recipients from header: " + headers.ToString() + "\r\nException: " + e.ToString());

                throw;
            }
        }
        public void Context()
        {
            var parser = new RecipientParser();

            _result = parser.Parse(@"""Tomas Marny"" <*****@*****.**>, John Smith <*****@*****.**>
                          [email protected]; ");
        }