private bool HandleMessage(IReceivedEmail email)
        {
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Email {0}:", _index++);
            Console.WriteLine("  From: {0}", email.From);
            Console.WriteLine("  Subject: {0}", email.Subject);

            try
            {
                var request = _requestRetriever.GetRequestFromEmail(email);

                if (request == null)
                    Console.WriteLine("  VCalendar not found");
                else
                {

                    var e = request.Event;
                    Console.WriteLine("  Event ID: {0}", e.EventId);
                    Console.WriteLine("  Summary: {0}", e.Summary);
                    Console.WriteLine("  Time: {0} to {1}", e.Start, e.End);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("  Error retrieving calendar: {0}", ex.ToString());
            }

            // pretend we failed so that we don't delete any emails
            return false;
        }
Exemplo n.º 2
0
        private bool HandleMessage(IReceivedEmail email, MailboxConnectionInfo mailboxInfo)
        {
            Console.Write("- Sending email to {0}...", email.From.ToString());

            EmailBuilder response = BuildResponse(email);
            _sender.SendEmail(mailboxInfo, response);

            Console.WriteLine(" Done");

            // pretend we failed so that we don't delete any emails
            return false;
        }
        /// <summary>
        /// Finds, parses, and returns a VCalendar request from an email, or returns null if none is found.
        /// </summary>
        /// <param name="email">The email to search</param>
        /// <returns>The VCalendar request, or null if none is found</returns>
        public EventRequestData GetRequestFromEmail(IReceivedEmail email)
        {
            // look for the section
            IReceivedEmailSection section = GetFirstCalendarSection(email.Sections);
            if (section == null)
                return null;

            EventRequestData request;
            using (var reader = section.GetContentTextReader())
            {
                request = _vcalendarParser.GetEventRequestFromVCardStream(reader);
            }

            return request;
        }
Exemplo n.º 4
0
        private EmailBuilder BuildResponse(IReceivedEmail email)
        {
            EmailBuilder response = new EmailBuilder();
            response.To.Add(email.From);
            response.Subject = "Thank you for your email";

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Hello {0},\r\n", email.From.Name ?? email.From.Address);
            sb.AppendLine();
            sb.AppendLine("Thank you for your email.");
            sb.AppendLine();
            sb.AppendLine("This system is not yet fully operational, so please bear with us while we build support for processing your requests.");
            sb.AppendLine();
            sb.AppendLine("Thanks,");
            sb.AppendLine("Themis System.");

            response.TextBody = sb.ToString();

            return response;
        }