sql - how I can resend all failed emails (msdb.dbo.sp_send_dbmail) -


i sending emails using msdb.dbo.sp_send_dbmail. emails not send. have got list of emails have failed.

select top 10 * msdb.dbo.sysmail_event_log    log_id  event_type  log_date    process_id  mailitem_id account_id  last_mod_date   last_mod_user 9022    error   50:15.9 5608    20428   null    50:15.9 sa 9023    error   51:23.3 5608    20428   null    51:23.3 sa 

now, want resend failed emails again available in sysmail_event_log table.

how can resend failed emails?

use following query sending failed item.
or use cursor each row msdb.dbo.sysmail_faileditems same query

declare @to        varchar(max) declare @copy    varchar(max) declare @title    nvarchar(255) declare @msg    nvarchar(max) select @to = recipients, @copy = copy_recipients, @title = [subject], @msg = body msdb.dbo.sysmail_faileditems mailitem_id =  56299 exec msdb.dbo.sp_send_dbmail @recipients = @to, @copy_recipients = @copy, @body = @msg, @subject = @title, @body_format = 'html'; 

references

resending-failed-emails-through-sp_send_email
cursor


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -