Email Sending event - multiple recipients

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
lfernandes
User
Posts: 77

Email Sending event - multiple recipients

Post by lfernandes »

I need to send notifications after editing and insertion actions. I am trying to use email Sending Event, but as I can send to many recipients.


MichaelG
User
Posts: 1110

Post by MichaelG »

Use the Email_Sending server event and comma separate the recipients.


lfernandes
User
Posts: 77

Post by lfernandes »

The following error is occurring when using Email Sending event :

public bool Email_Sending(EmailBase email, dynamic? args) {
//Log(email, args); // View the arguments
if (CurrentPageID() == "add") { // If Add page
email.Recipient = ConvertToString(args?["rsnew"]["Email"]); // Change recipient to a field value in the new record
email.Subject = "[##"+ConvertToString(args["rsnew"]["IDTicket"])+"##] Seu ticket foi Editado"; // Change subject
email.Content += "<p>Added by " + CurrentUserName() + "</p>"; // Append additional content
}
return true;
}

An unhandled exception occurred while processing the request.
SocketException: O nome solicitado é válido, mas não foram encontrados dados do tipo solicitado.
MailKit.Net.SocketUtils.ConnectAsync(string host, int port, IPEndPoint localEndPoint, bool doAsync, CancellationToken cancellationToken)

Stack Query Cookies Headers Routing
SocketException: O nome solicitado é válido, mas não foram encontrados dados do tipo solicitado.
MailKit.Net.SocketUtils.ConnectAsync(string host, int port, IPEndPoint localEndPoint, bool doAsync, CancellationToken cancellationToken)
MailKit.Net.SocketUtils.ConnectAsync(string host, int port, IPEndPoint localEndPoint, int timeout, bool doAsync, CancellationToken cancellationToken)
MailKit.MailService.ConnectNetwork(string host, int port, bool doAsync, CancellationToken cancellationToken)
MailKit.Net.Smtp.SmtpClient.ConnectAsync(string host, int port, SecureSocketOptions options, bool doAsync, CancellationToken cancellationToken)
ASPNETMaker2023.Models.ead2024.SendEmailAsync(string from, string to, string cc, string bcc, string subject, string body, string format, string charset, SecureSocketOptions options, List<Dictionary<string, string>> attachments, List<string> images, SmtpClient smtp) in aspnetfn.cs
+
await smtp.ConnectAsync(host, port, options);
ASPNETMaker2023.Models.ead2024+Email.SendAsync() in Email.cs
+
bool send = await SendEmailAsync(Sender, Recipient, Cc, Bcc, Subject, Content, Format, Charset, Options, Attachments, EmbeddedImages, Mailer);
ASPNETMaker2023.Models.ead2024+HdkTpTickets.SendEmailOnAdd(Dictionary<string, object> rs) in HdkTpTickets.cs
+
emailSent = await email.SendAsync();
ASPNETMaker2023.Models.ead2024+HdkTpTicketsAddBase.AddRow(Dictionary<string, object> rsold) in HdkTpTicketsAdd.cs
+
var res = await SendEmailOnAdd(rsnew); // DN
ASPNETMaker2023.Models.ead2024+HdkTpTicketsAddBase.Run() in HdkTpTicketsAdd.cs
+
var res = await AddRow(rsold);
ASPNETMaker2023.Controllers.HomeController.HdkTpTicketsAdd() in HdkTpTicketsController.cs
+
return await hdkTpTicketsAdd.Run();
Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>gAwaited|12_0(ControllerActionInvoker invoker, ValueTask<IActionResult> actionResultValueTask)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g
Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>gAwaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g
Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>gAwaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g
Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g
AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Marvin.Cache.Headers.HttpCacheHeadersMiddleware.HandleResponse(HttpContext httpContext)
Marvin.Cache.Headers.HttpCacheHeadersMiddleware.Invoke(HttpContext httpContext, IValidatorValueInvalidator validatorValueInvalidator)
Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)


MichaelG
User
Posts: 1110

Post by MichaelG »

Make sure that the email recipient is valid and your SMTP settings are correct.


Post Reply