public void SendFile()
		{
			ReportRecipient recipient = new ReportRecipient();
			recipient.Email = "*****@*****.**";
			recipient.Name = "Marnee Dearman";

			_emailService = SetupEmailService();

			Email email = new Email();
			email.To = recipient.Email;
			email.From = "*****@*****.**";
			email.Message = "Report attached";
			email.Subject = "ICMS TEST AUTO ORDER SEND";
			email.Attachments = new List<string>();
			email.Attachments.Add(@"C:\Users\Marnee Dearman\Documents\SK Auto\ICMS Excel Downloads\TESTattachments\test.txt");

			_emailService.Send(email);
			
		}
        public ActionResult SendReports()
        {
            DateTime date = DateTime.Now;
            string reportDateTime = date.ToString("d", _culture);

            //TODO get config from web.config
            ReportConfig reportConfig = new ReportConfig();
            reportConfig.DeviceInfo =
                "<DeviceInfo>" +
                " <OutputFormat>Excel</OutputFormat>" +
                " <PageWidth>11in</PageWidth>" +
                "</DeviceInfo>";
            reportConfig.ReportServerUrl = new Uri(@"http://puketi/ReportServer_SQL2012EXPRESS");
            reportConfig.ReportPath = "/ICMS/OrdBySalAreaSum_ICMS";
            reportConfig.SaveTo = @"C:\RenderedReports\ICMSOrderSummaryReport.xls";
            reportConfig.SaveFormat = "Excel";

            _reportService.RenderReport(reportConfig);

            IList<ReportRecipient> recipients = _reportRecipientRepository.GetList();
            foreach (ReportRecipient recip in recipients)
            {
                Email email = new Email();
                email.Attachments.Add(reportConfig.SaveTo);
                email.To = recip.Email;
                email.From = "*****@*****.**"; //TODO get from config
                email.Subject = "ICMS Order Summary Report"; //TODO get from config
                email.Message = "Order report attached.";

                _emailService.Send(email);
            }

            return Content(string.Format("Successfully sent {0} reports", "1"));
        }
		public ActionResult Login(PasswordlessViewModel model, string returnUrl)
		{
			//TODO encapsulate this logic?  do I want to inject this?

			if (ModelState.IsValid)
			{
				//if email address found in system
				//send login request confirmation to email address

				//hash auth url
				System.Collections.Generic.IDictionary<string, string> hashValues = new System.Collections.Generic.Dictionary<string, string>();
				hashValues["Email"] = model.Email;
				System.Diagnostics.Trace.TraceError(string.Format("Creating auth token."));
				string urlToken = _userAuthentication.CreateAuthToken(hashValues, Guid.NewGuid().ToString(), ConfigurationManager.AppSettings["SecretHashKey"]);
				System.Diagnostics.Trace.TraceError(string.Format("Created URL token [{0}] for email [{1}]", urlToken, model.Email));
				if (_userAuthentication.SetAuthToken(urlToken, model.Email))
				{
					string host = Request.Url.Host;
					UriBuilder bb = new UriBuilder("https", host + "/account/authorize");  //TODO build URI based on configuration?
					System.Collections.Specialized.NameValueCollection query = System.Web.HttpUtility.ParseQueryString(string.Empty);
					query["authtoken"] = urlToken;
					query["email"] = model.Email;
					query["returnUrl"] = returnUrl;
					bb.Query = query.ToString();
					string url = bb.ToString();

					//SEND VERIFICATION EMAIL
					string message = "A request was made for access to the ICMS. <br />";
					message += "Please follow the link below to complete the request and login to the ICMS. <br />";
					message += string.Format("The login request will expire in 10 minutes at {0}. <br />", DateTime.Now.AddMinutes(10));
					message += url;
					message += "<br/ ><br />";
					message += "ICMS TERMINAL MANAGEMENT";
					Email email = new Email();
					email.Message = message;
					email.To = model.Email;
					email.From = System.Configuration.ConfigurationManager.AppSettings["IcmsEmail"];
					email.Subject = "ICMS: REQUEST FOR ACCESS";
					try
					{
						_emailService.Send(email);
						_logger.Trace(string.Format("Authentication email sent to user [{0}]", model.Email));
					}
					catch (Exception ex)
					{
						_logger.Error(string.Format("FAILED SEND AUTHENTICATION EMAIL [{0}]", ex.Message));
						System.Diagnostics.Trace.TraceError(string.Format("FAILED SEND AUTHENTICATION EMAIL [{0}]", ex.Message));
					}
				}
			}

			return View(model);
		}