public void SendEmail(EBook book, string toEmail) { try { //put these in a config file. Encrypt? NetworkCredential credentials = new NetworkCredential("", ""); FileTypeConverter ftc = new FileTypeConverter(); MailMessage mail = new MailMessage(new MailAddress(""), new MailAddress(toEmail)); mail.Subject = "ebook"; mail.Body = ""; if (book.fileType != ".mobi") { book.fileLocation = ftc.ConvertToMobi(book.fileLocation, book.coverImageLocation); if (book.fileLocation == "") { return; } } mail.Attachments.Add(new Attachment(book.fileLocation)); SmtpClient client = new SmtpClient(); client.EnableSsl = true; client.Port = 587; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "smtp.gmail.com"; client.Credentials = credentials; client.Send(mail); } catch (Exception ex) { //TODO handle error return; } }
public void Deconvolute() { try { bool areRequirementsMet = validateDeconRequirements(); if (areRequirementsMet) { state = DeconState.RUNNING_DECON; this.oldschoolprocRunner = new OldSchoolProcRunner(this.dataFile, FileTypeConverter.ConvertDeconEngineFileType(fileType), this.paramFile, null); this.oldschoolprocRunner.IsosResultThreshold = 50000; this.oldschoolprocRunner.Execute(); state = DeconState.DONE; } else { return; } } catch (Exception ex) { EventLog elog = new EventLog(); elog.Log = "Application"; elog.Source = "Decon2LS"; elog.WriteEntry(ex.Message + ex.StackTrace); elog.Close(); state = DeconState.ERROR; throw ex; } }