Exemple #1
0
        public bool SendEmailViaGmail(BookingEntity booking, bool isFinal)
        {
            SmtpClient client = new SmtpClient();
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.EnableSsl = true;
            client.Host = "smtp.gmail.com";
            client.Port = 587;

            var securityCode = new Guid();

            // setup Smtp authentication
            NetworkCredential credentials =
                new NetworkCredential("*****@*****.**", "T!T@n1130");
            client.UseDefaultCredentials = false;
            client.Credentials = credentials;

            MailMessage msg = new MailMessage();
            msg.From = new MailAddress("*****@*****.**");
            msg.To.Add(new MailAddress(booking.Email));

            msg.IsBodyHtml = true;
            if (isFinal)
            {
                msg.Subject = "Booking information";
                msg.Body = "<html><head></head><body><b>Thanks for booking! We will be in touch with you shortly!</b></body>";
            }
            else
            {
                msg.Subject = "This is a test Email subject";
                msg.Body = string.Format("<html><head></head><body><b>?confirmation={0}</b></body>", booking.ConfirmationCode);
            }

            try
            {
                client.Send(msg);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Exemple #2
0
 public void InsertEventToCalendar(BookingEntity booking)
 {
     //Inserting event to calendar
     Event event1 = new Event()
     {
         Summary = String.Format("Route: {0} - {1}, Client: {2}",booking.PickUpLocation, booking.DropLocation, booking.Name),
         Location = booking.PickUpLocation,
         Start = new EventDateTime()
         {
             DateTime = booking.PickUpDateTime,
             //DateTime = new DateTime(2015, 12, 11, 14, 15, 0),
             TimeZone = "Europe/London"
         },
         End = new EventDateTime()
         {
             DateTime = booking.PickUpDateTime.Add(booking.TransferTime),
             //DateTime = new DateTime(2015, 12, 11, 15, 15, 0),
             TimeZone = "Europe/London"
         },
     };
     service.Events.Insert(event1, "primary").Execute();
 }