Open Closed

background job #5154


User avatar
0
Zahra created
  • ABP Framework version: v7
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Separated server
  • Exception message and stack trace: I am want to send email to list of users on background job >>>
  • if i give a name for background job its work next time its not work until i change the name again
  • so it need to change the name each time i want to send email

how i can use unique name for the email??

*

  • Steps to reproduce the issue:"

11 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    What is the name?

    Can you share some code?

  • User Avatar
    0
    Zahra created

    on Application.Contracts Layers

    [BackgroundJobName("EmailSendingArgs2")]
    public class EmailSendingArgs
    {
        public List<string>? EmailAddressList { get; set; }
        public string? Subject { get; set; }
        public string? Body { get; set; }
        
    }
    

    on Application Layers

    public class EmailSendingJob : AsyncBackgroundJob<EmailSendingArgs>, ITransientDependency
    	{
    		private readonly IEmailSender _emailSender;
    
    		public EmailSendingJob(IEmailSender emailSender)
    		{
    			_emailSender = emailSender;
    		}
    
    		public override async Task  ExecuteAsync(EmailSendingArgs args)
    		{
    			foreach (string emailAddress in args.EmailAddressList)
    			{
    				await _emailSender.SendAsync(
    					emailAddress,
    					args.Subject,
    					args.Body
    				);
    			}
    
    		}
    	}
    
    

    on AppService

     await _backgroundJobManager.EnqueueAsync(
                                    new EmailSendingArgs
                                    {
                                        EmailAddressList = emailAddressList,
                                        Subject = subject,
                                        Body = emailBody
                                    }
                                );
                                ```
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I think the code is no problem, I don't understand it very well. How to reproduce?

  • User Avatar
    0
    Zahra created

    if I invent some peoples for a meetings ..it will send an email for all of them

  • User Avatar
    0
    Zahra created

    maybe their is configuration I forget to write

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I still don't know your problem.

    Can you explain in more detail?

  • User Avatar
    0
    Zahra created

    background job dose not work ...I don't know why

    I send for you the code and this is the error

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Ok, I see.

    Please share the error/exception info next time.

    I will check this.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a minimal project to reproduce the problem?

    liming.ma@volosoft.com

    Thanks

  • User Avatar
    0
    Zahra created

    I can not send my project because it is private

    I think you can solve it without my project

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can test your code in a new template project.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11