private async Task <IActionResult> Upload([FromForm] CreateSendedEmail command) { List <FileModel> fileModels = new List <FileModel> (); foreach (var file in command.Attachments) { if (file.Length > 0) { using (var ms = new MemoryStream()) { var fileModel = new FileModel(); file.CopyTo(ms); fileModel.Store = ms.ToArray(); fileModel.ContentType = file.ContentType; fileModel.FileName = file.FileName; fileModels.Add(fileModel); } } } await Task.CompletedTask; var returnFile = fileModels.ElementAt(1); // var msa = await Zip.GetZipStream (fileModels); // return File (msa.ToArray (), "application/zip", "Attachments.zip"); return(Ok()); }
public async Task <IActionResult> SendEmailMessage([FromForm] CreateSendedEmail command) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await _sendedEmailMessageService.SendAsync(UserId, command.From, command.To, command.Cc, command.Bcc, command.Subject, command.TextHTMLBody, command.Attachments); return(StatusCode(201)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <IActionResult> Send([FromBody] CreateSendedEmail command) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = await _userRepository.GetWithEmailAccountsAsync(UserId); if (user == null) { return(Unauthorized()); } try { // await _emailAccountService.CreateAsync (user, command.Email, command.Password, command.ImapHost, command.ImapPort, command.SmtpHost, command.SmtpPort); } catch (Exception e) { return(BadRequest(e.Message)); } return(StatusCode(201)); }