private ObservableCollection <FileAttachmentModel> PrepareData() { FilesAttachment.Add(new FileAttachmentModel() { FileName = "TrackA", FilePath = "D:\trackA.png" }); FilesAttachment.Add(new FileAttachmentModel() { FileName = "TrackB", FilePath = "D:\trackB.png" }); FilesAttachment.Add(new FileAttachmentModel() { FileName = "TrackC", FilePath = "D:\trackC.png" }); FilesAttachment.Add(new FileAttachmentModel() { FileName = "TrackD", FilePath = "D:\trackD.png" }); FilesAttachment.Add(new FileAttachmentModel() { FileName = "TrackE", FilePath = "D:\trackE.png" }); FilesAttachment.Add(new FileAttachmentModel() { FileName = "TrackF", FilePath = "D:\trackF.png" }); FilesAttachment.Add(new FileAttachmentModel() { FileName = "TrackG", FilePath = "D:\trackG.png" }); return(FilesAttachment); }
private void AddFileAttachment(object obj) { using (System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog()) { if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var size = new FileInfo(fileDialog.FileName).Length; long mb = size / (1024 * 1024); if (mb > 30) { MessageBox.Show("Your file is greater than 30MB, file must be less 30MB!", "Message", MessageBoxButton.OK, MessageBoxImage.Information); return; } else { FilesAttachment.Add(new FileAttachmentModel() { FileName = System.IO.Path.GetFileName(fileDialog.FileName), FilePath = fileDialog.FileName }); } } } AllowReset = true; }
private async void SendMail(object obj) { string message = ""; if (string.IsNullOrEmpty(MailAddresses) || string.IsNullOrEmpty(MailSubject)) { message = "Please enter mail addresses and subject!"; } else { int result = await SPCMail.Instance.PrepareSPCMail(Properties.Settings.Default._hostUser, MailAddresses, MailSubject, DocumentXaml, MailCc, FilesAttachment.Select(f => f.FilePath).ToArray()); if (result == -1) { message = "Something went wrong, please check out mail addresses!"; } else if (result == 1) { message = "Mail(s) sent successfully!"; } else { message = "There is no mail sent!"; } } MessageBox.Show(message, "Message", MessageBoxButton.OK, MessageBoxImage.Information); }