Beispiel #1
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            MailMessage message = base.MailMessage.Get(context);

            MailHelper recipients = new MailHelper(message.To);

            //Create collection of original recipients
            recipients.AddAddresses(message.CC);
            recipients.AddAddresses(message.Bcc);

            //Add new recipients to collection
            recipients.AddAddresses(base.AdditionalCc.Get(context));
            recipients.AddAddresses(base.AdditionalCc.Get(context));
            recipients.AddAddresses(base.Bcc.Get(context));

            //Validate will throw an exception if any recipient's domain is not in the permitted list
            //If an exception is thrown, the function will exit prior to sending the mail (happens in the base.ExecuteAsync function)
            recipients.ValidateAddresses(MailConstraintSettings.MailHelper);

            //If no exception is thrown by the validation check, call the base class's "ExecuteAsync"
            //which will send the message per the settings
            await base.ExecuteAsync(context, cancellationToken);

            return(_ => { });
        }
Beispiel #2
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            MailHelper recipients = new MailHelper();

            //Retrieve the values stored in the activities To, Cc, and Bcc properties
            recipients.AddAddresses(base.To.Get(context));
            recipients.AddAddresses(base.Cc.Get(context));
            recipients.AddAddresses(base.Bcc.Get(context));

            //Validate will throw an exception if any recipient's domain is not in the permitted list
            //If an exception is thrown, the function will exit prior to sending the mail (happens in the base.ExecuteAsync function)
            recipients.ValidateAddresses(MailConstraintSettings.MailHelper);

            //If no exception is thrown by the validation check, call the base class's "ExecuteAsync"
            //which will send the message per the settings
            await base.ExecuteAsync(context, cancellationToken);

            return(_ => { });
        }