* Added EmailAddresses and WzNumbers to WzHeader
* Changed approach to send email to addresses added to WzHeader
This commit is contained in:
@@ -88,8 +88,8 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
|
||||
using MemoryStream stream = new MemoryStream();
|
||||
workbook.SaveAs(stream);
|
||||
stream.Position = 0;
|
||||
|
||||
SendEmail(stream);
|
||||
|
||||
SendEmail(stream, wzHeader);
|
||||
}
|
||||
|
||||
private static string GetColumnLetter(int columnIndex)
|
||||
@@ -104,7 +104,7 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
|
||||
return columnName;
|
||||
}
|
||||
|
||||
private void SendEmail(MemoryStream stream)
|
||||
private void SendEmail(MemoryStream stream, WzHeaderDto wzHeader)
|
||||
{
|
||||
IConfigurationSection smtpSettings = configuration.GetSection("EmailSettings");
|
||||
string smtpHost = smtpSettings["SmtpServer"] ?? string.Empty;
|
||||
@@ -112,7 +112,8 @@ public class ExcelGeneratorController(IWzHeaderService wzHeaderService, IMateria
|
||||
string smtpUsername = smtpSettings["SenderEmail"] ?? string.Empty;
|
||||
string smtpPassword = smtpSettings["SenderPassword"] ?? string.Empty;
|
||||
string fromEmail = smtpSettings["SenderEmail"] ?? string.Empty;
|
||||
List<string> toEmail = (smtpSettings["RecipientEmail"] ?? string.Empty).Split(',').ToList();
|
||||
List<string> toEmail = wzHeader.EmailAddresses?.Split(',')?.ToList() ??
|
||||
(smtpSettings["RecipientEmail"] ?? string.Empty).Split(',').ToList();
|
||||
string subject = "MEYLE: Packing List";
|
||||
string body =
|
||||
$"W załączeniu znajduje się Packing List dla klienta MEYLE wygenerowany {DateTime.Now:dd.MM.yyyy HH:mm:ss}";
|
||||
|
||||
Reference in New Issue
Block a user