public async Task <IActionResult> Send(SendRequest sendRequest) { //初使化 Initialize(sendRequest); var email = EmailSend .From(sendRequest.FromEmail) .To(sendRequest.ToEmail) .Body(sendRequest.Body, true); //使用模板发送 if (sendRequest.TemplateModel != null && !string.IsNullOrEmpty(sendRequest.Template)) { email.UsingTemplate(sendRequest.Template, sendRequest.TemplateModel); } //发送附件 if (sendRequest.Attachment != null) { email.Attach(sendRequest.Attachment); } var response = await email.SendAsync(); return(new JsonResult(response)); }