/// <summary> /// Returns a list of bounced emails. Paramenter tells whether soft bounces should also be returned. /// </summary> public List<BouncedEmail> BouncedEmails( bool includeSoftBounces ) { List<BouncedEmail> bouncedItems = new List<BouncedEmail>(); string URLString = String.Format( "{0}/api/bounces.get.xml?api_user={1}&api_key={2}&date=1", _urlBase, _userName, _password ); if ( !includeSoftBounces ) URLString += "&type=hard"; XDocument xdoc = XDocument.Load( URLString ); var bounces = from bounce in xdoc.Descendants( "bounce" ) select new { Status = bounce.Element( "status" ).Value, Created = bounce.Element( "created" ).Value, Reason = bounce.Element( "reason" ).Value, Email = bounce.Element( "email" ).Value }; foreach ( var bounce in bounces ) { BouncedEmail email = new BouncedEmail(); email.Email = bounce.Email; email.Reason = bounce.Reason; email.Status = bounce.Status; email.Created = Convert.ToDateTime( bounce.Created ); bouncedItems.Add( email ); } return bouncedItems; }
/// <summary> /// Returns a list of bounced emails. Paramenter tells whether soft bounces should also be returned. /// </summary> public List <BouncedEmail> BouncedEmails(bool includeSoftBounces) { List <BouncedEmail> bouncedItems = new List <BouncedEmail>(); string URLString = String.Format("{0}/api/bounces.get.xml?api_user={1}&api_key={2}&date=1", _urlBase, _userName, _password); if (!includeSoftBounces) { URLString += "&type=hard"; } XDocument xdoc = XDocument.Load(URLString); var bounces = from bounce in xdoc.Descendants("bounce") select new { Status = bounce.Element("status").Value, Created = bounce.Element("created").Value, Reason = bounce.Element("reason").Value, Email = bounce.Element("email").Value }; foreach (var bounce in bounces) { BouncedEmail email = new BouncedEmail(); email.Email = bounce.Email; email.Reason = bounce.Reason; email.Status = bounce.Status; email.Created = Convert.ToDateTime(bounce.Created); bouncedItems.Add(email); } return(bouncedItems); }