This commit is contained in:
@@ -9,7 +9,7 @@ namespace AyaNova.Util
|
||||
{
|
||||
public interface IMailer
|
||||
{
|
||||
Task SendEmailAsync(string email, string subject, string body, AyaNova.Models.GlobalOpsNotificationSettings smtpSettings, string attachPDF = null);
|
||||
Task SendEmailAsync(string email, string subject, string body, AyaNova.Models.GlobalOpsNotificationSettings smtpSettings, string attachPDF = null, string forceFileName = null);
|
||||
}
|
||||
|
||||
public class Mailer : IMailer
|
||||
@@ -19,7 +19,7 @@ namespace AyaNova.Util
|
||||
|
||||
}
|
||||
|
||||
public async Task SendEmailAsync(string email, string subject, string body, AyaNova.Models.GlobalOpsNotificationSettings smtpSettings, string attachPDFPath = null)
|
||||
public async Task SendEmailAsync(string email, string subject, string body, AyaNova.Models.GlobalOpsNotificationSettings smtpSettings, string attachPDFPath = null, string forceFileName = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -29,17 +29,18 @@ namespace AyaNova.Util
|
||||
message.Subject = subject;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(attachPDFPath))
|
||||
{
|
||||
{
|
||||
var attachment = new MimePart("application/pdf", "pdf")
|
||||
{
|
||||
Content = new MimeContent(File.OpenRead(attachPDFPath), ContentEncoding.Default),
|
||||
ContentDisposition = new ContentDisposition(ContentDisposition.Attachment),
|
||||
ContentTransferEncoding = ContentEncoding.Base64,
|
||||
FileName = Path.GetFileName("test.pdf")
|
||||
//FileName = Path.GetFileName(attachPDFPath)
|
||||
FileName = Path.GetFileName(attachPDFPath)
|
||||
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(forceFileName))
|
||||
attachment.FileName = forceFileName;
|
||||
|
||||
var multipart = new Multipart("mixed");
|
||||
if (!string.IsNullOrWhiteSpace(body))
|
||||
multipart.Add(new TextPart(TextFormat.Plain) { Text = body });
|
||||
|
||||
Reference in New Issue
Block a user