public async Task <IActionResult> DownloadAttachments(int emailId) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var attachmentsStream = await _emailMessageService.GetUserAttachmentsAsync(UserId, emailId); return(File(attachmentsStream.ToArray(), "application/zip", "Attachments.zip")); } catch (Exception e) { return(BadRequest(e.Message)); } }