public IActionResult SendMail(int x40id) { var v = new Models.SendMailViewModel(); v.Rec = new BO.x40MailQueue(); v.Rec.j40ID = BO.BAS.InInt(Factory.CBL.LoadUserParam("SendMail_j40ID")); v.Rec.j40Name = Factory.CBL.LoadUserParam("SendMail_j40Name"); v.Rec.x40MessageGuid = BO.BAS.GetGuid(); v.UploadGuid = BO.BAS.GetGuid(); if (x40id > 0) { //kopírování zprávy do nové podle vzoru x40id v.Rec = Factory.MailBL.LoadMessageByPid(x40id); v.Rec.x40To = v.Rec.x40To; v.Rec.x40Cc = v.Rec.x40Cc; v.Rec.x40Bcc = v.Rec.x40Bcc; v.Rec.x40Subject = v.Rec.x40Subject; v.Rec.x40Body = v.Rec.x40Body; var vtemp = new x40RecordViewModel(); vtemp.Rec = v.Rec; InhaleMimeMessage(ref vtemp, v.UploadGuid); } return(View(v)); }
private void InhaleMimeMessage(ref x40RecordViewModel v, string strDestGUID) { string fullPath = Factory.App.UploadFolder + "\\" + v.Rec.x40EmlFolder + "\\" + v.Rec.x40MessageGuid + ".eml"; if (System.IO.File.Exists(fullPath) == false) { return; } v.MimeMessage = MimeMessage.Load(fullPath); v.MimeAttachments = new List <BO.StringPair>(); foreach (var attachment in v.MimeMessage.Attachments) { if (attachment is MessagePart) { } else { var part = (MimePart)attachment; var fileName = part.FileName; v.MimeAttachments.Add(new BO.StringPair() { Key = part.ContentType.MimeType, Value = fileName }); string strTempFullPath = this.Factory.App.TempFolder + "\\" + strDestGUID + "_" + fileName; if (System.IO.File.Exists(strTempFullPath) == false) { using (var fs = new FileStream(strTempFullPath, System.IO.FileMode.Create)) { part.Content.DecodeTo(fs); //uložit attachment soubor do tempu } } } } }