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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -