Bug Affects...
[x] Razor templating and
[x] C# and .net API
Current Behavior / Expected Behavior
Here are the 2sxc docs for .Create().
If I try to send an email like this I get an error:
var message = Kit.Mail.Create(
from: "My Website <noreply@accuraty.com>",
to: emailTo,
bcc: emailBcc,
subject: $"Careers / Job Listings - New Draft(s) Available for Review",
body: emailBody
);
Kit.Mail.Send(message);
The .Send() throws an error:
Error: System.ArgumentException: Unknown type for attachments at ToSic.Sxc.Services.Mail.Sys.MailServiceBase.AddAttachments(AttachmentCollection targetAttachments, Object attachments) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc.Services\Services\Mail\Sys\MailServiceBase.cs:line 206 at ToSic.Sxc.Services.Mail.Sys.MailServiceBase.Create(NoParamOrder npo, Object from, Object to, Object cc, Object bcc, Object replyTo, String subject, String body, Nullable`1 isHtml, Encoding encoding, Object attachments) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc.Services\Services\Mail\Sys\MailServiceBase.cs:line 73 at RazorHost.RazorViewISAAJobslist.Execute() in D:\HostingSpaces\ISAA\isa-arbor.com\www\Portals\0\2sxc\JobListings\ISAA-Jobs-list.cshtml🎯:line 131
2sxc follows a consistent pattern where there is a default specified, so I should not need to specify an empty attachments object. However, if I add the parameter:
body: emailBody,
attachments: Array.Empty<System.Net.Mail.Attachment>()
);
It works and does not throw the error.
Your environment
- 2sxc version(s): 21.7.0
- Browser: all or n/a
- DNN: same on 9.13.10 and 10.02.05
- Hosting platform: IIS
- Ui Languages: any/all | English
Bug Affects...
[x] Razor templating and
[x] C# and .net API
Current Behavior / Expected Behavior
Here are the 2sxc docs for .Create().
If I try to send an email like this I get an error:
The
.Send()throws an error:2sxc follows a consistent pattern where there is a default specified, so I should not need to specify an empty attachments object. However, if I add the parameter:
It works and does not throw the error.
Your environment