添加收件人信息
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Service;
|
||||
public interface IEmailHandleService
|
||||
{
|
||||
Task<bool> HandleEmailAsync(
|
||||
string to,
|
||||
string from,
|
||||
string subject,
|
||||
DateTime date,
|
||||
@@ -23,6 +24,7 @@ public class EmailHandleService(
|
||||
) : IEmailHandleService
|
||||
{
|
||||
public async Task<bool> HandleEmailAsync(
|
||||
string to,
|
||||
string from,
|
||||
string subject,
|
||||
DateTime date,
|
||||
@@ -42,7 +44,7 @@ public class EmailHandleService(
|
||||
return false;
|
||||
}
|
||||
|
||||
var emailMessage = await SaveEmailAsync(from, subject, date, body);
|
||||
var emailMessage = await SaveEmailAsync(to, from, subject, date, body);
|
||||
|
||||
if (emailMessage == null)
|
||||
{
|
||||
@@ -151,6 +153,7 @@ public class EmailHandleService(
|
||||
}
|
||||
|
||||
private async Task<EmailMessage?> SaveEmailAsync(
|
||||
string to,
|
||||
string from,
|
||||
string subject,
|
||||
DateTime date,
|
||||
@@ -185,6 +188,9 @@ public class EmailHandleService(
|
||||
}
|
||||
|
||||
emailEntity.Md5 = emailMd5;
|
||||
var toName = emailSettings.Value.SmtpList
|
||||
.FirstOrDefault(s => s.Email == to)?.Name ?? "";
|
||||
emailEntity.To = string.IsNullOrEmpty(toName) ? to : $"{toName} <{to}>";
|
||||
var ok = await emailRepo.AddAsync(emailEntity);
|
||||
if (ok)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user