Exemple #1
0
        public void GetThumbnailPath()
        {
            var save = new SavePhoto(1);

            photoNumber = save.PhotoNumberJustTaken();
            string photoName = save.photoNaming(photoNumber);

            thumbnailPath = Path.Combine(Actual.FilePath(), photoName);
        }
Exemple #2
0
        public async void SendEmail(int photoNumber, int numberOfPhotosToSendViaEmail, string emailClientAddress)
        {
            try
            {
                await Task.Run(() =>
                {
                    LoadValues();
                    MailMessage mail = new MailMessage();
                    //put your SMTP address and port here.
                    SmtpClient SmtpServer = new SmtpClient(smtpServerName);
                    //Put the email address
                    mail.From = new MailAddress(emailHostAddress);
                    //Put the email where you want to send.
                    //TODO: Regexp sprawdzajacy poprawny e-mail
                    mail.To.Add(emailClientAddress);

                    mail.Subject = "Test1234Topic";

                    StringBuilder sbBody = new StringBuilder();

                    sbBody.AppendLine("Hi, this is test mail");

                    mail.Body = sbBody.ToString();

                    var instance = new SavePhoto(photoNumber);
                    for (int i = 0; i < numberOfPhotosToSendViaEmail; i++)
                    {
                        photoNumber = (instance.PhotoNumberJustTaken() - i);
                        Debug.WriteLine("photo number is: " + photoNumber);
                        string photoName          = instance.photoNaming(photoNumber);
                        string photoDirectoryPath = Path.Combine(Actual.FilePath(), photoName);
                        Debug.WriteLine(photoDirectoryPath);
                        Attachment attachment = new Attachment(photoDirectoryPath);
                        mail.Attachments.Add(attachment);
                    }

                    /// mail - [email protected]
                    /// pass - Photomadness123
                    /// Server name: smtp-mail.outlook.com
                    //Port: 587
                    //TODO:dodac mozliwosc podmiany maili
                    SmtpServer.Credentials = new NetworkCredential(emailHostAddress, emailHostPassword);
                    SmtpServer.Port        = int.Parse(smtpPortNumber);
                    SmtpServer.EnableSsl   = true;

                    SmtpServer.Send(mail);
                });
            }
            catch (FormatException) { Report.Error("Wrong e-mail format \nPlease enter your e-mail correctly\[email protected]", true); }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }