入货通知发送

optimize
wanghaomei 2 years ago
parent 6c537acb74
commit 55db99f034

@ -2209,6 +2209,11 @@ namespace Myshipping.Application
throw Oops.Bah("放舱信息未找到,请先保存数据");
}
if (string.IsNullOrEmpty(letterYard.AttnMail))
{
throw Oops.Bah("ATTN MAIL未正确填写");
}
var mailAcc = await _repUserMail.FirstOrDefaultAsync(x => x.CreatedUserId == user.Id && x.MailAccount == letterYard.AttnMail && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != "");
if (mailAcc == null)
{
@ -2221,11 +2226,6 @@ namespace Myshipping.Application
// throw Oops.Bah("未生成链接信息,请重新保存数据");
//}
if (string.IsNullOrEmpty(letterYard.AttnMail))
{
throw Oops.Bah("ATTN MAIL未正确填写");
}
#region 保存放舱文件,并挂载到订舱附件
var fileBytes = await GetReportFile(bookingId, "fangcang");
var opt = App.GetOptions<BookingAttachOptions>();
@ -2316,7 +2316,7 @@ namespace Myshipping.Application
{user.Email}
<br/>";
var sendResult = await MailSendHelper.SendMail(mailAcc, mailSubject, mailContent, letterYard.AttnMail);
var sendResult = await MailSendHelper.SendMail(mailAcc, mailSubject, mailContent, letterYard.AttnMail, new KeyValuePair<string, byte[]>(fileSaveName, fileBytes));
if (!sendResult.Key)
{
_logger.LogError($"放舱邮件发送失败:从{mailAcc.MailAccount}到{letterYard.AttnMail},主题 {mailSubject}");

@ -21,7 +21,8 @@ namespace Myshipping.Core.Helper
/// <param name="subject"></param>
/// <param name="body"></param>
/// <param name="sendTo"></param>
public static async Task<KeyValuePair<bool, string>> SendMail(DjyUserMailAccount acc, string subject, string body, string sendTo)
/// <param name="attachList">附件列表key为附件名称value为文件字节数组</param>
public static async Task<KeyValuePair<bool, string>> SendMail(DjyUserMailAccount acc, string subject, string body, string sendTo, params KeyValuePair<string, byte[]>[] attachList)
{
SmtpClient client = null;
try
@ -58,16 +59,33 @@ namespace Myshipping.Core.Helper
}
message.Subject = subject;
message.Sender = MailboxAddress.Parse(acc.MailAccount);
var html = new TextPart("html")
{
Text = body
};
MimeEntity entity = html;
if (attachList != null && attachList.Length > 0)
{
var mult = new Multipart("mixed") { html };
message.Sender = MailboxAddress.Parse(acc.MailAccount);
message.Body = entity;
foreach (var item in attachList)
{
var attPart = new MimePart();
attPart.Content = new MimeContent(new MemoryStream(item.Value));
attPart.ContentDisposition = new ContentDisposition(ContentDisposition.Attachment);
attPart.ContentTransferEncoding = ContentEncoding.Base64;
attPart.FileName = "=?UTF-8?B?" + Convert.ToBase64String(Encoding.UTF8.GetBytes(item.Key)) + "?=";
mult.Add(attPart);
}
message.Body = mult;
}
else
{
message.Body = html;
}
using (client = new SmtpClient())
{

@ -5557,7 +5557,7 @@
<param name="title">标题</param>
<param name="content">内容</param>
</member>
<member name="M:Myshipping.Core.Helper.MailSendHelper.SendMail(Myshipping.Core.Entity.DjyUserMailAccount,System.String,System.String,System.String)">
<member name="M:Myshipping.Core.Helper.MailSendHelper.SendMail(Myshipping.Core.Entity.DjyUserMailAccount,System.String,System.String,System.String,System.Collections.Generic.KeyValuePair{System.String,System.Byte[]}[])">
<summary>
使用用户邮箱配置发送邮件
</summary>
@ -5565,6 +5565,7 @@
<param name="subject"></param>
<param name="body"></param>
<param name="sendTo"></param>
<param name="attachList">附件列表key为附件名称value为文件字节数组</param>
</member>
<member name="M:Myshipping.Core.Helper.NpoiExcelExportHelper.CreateRow(NPOI.SS.UserModel.ISheet,System.Int32)">
<summary>

Loading…
Cancel
Save