Yuri,
Database Mail uses Service Broker behind the scenes so basically sp_send_dbmail queues the messages and then Service Broker processes the messages. So as long as the mail item is placed in the queue you will not get a mail sent or failed message.
sp_send_dbmail does return @mailitem_id as an output parameter so you can then run a query like this:
SELECT
SA.mailitem_id,
SA.recipients,
SA.copy_recipients,
SA.blind_copy_recipients,
SA.subject,
SA.sent_status,
SA.sent_date,
SEL.event_type,
SEL.log_date,
SEL.description
FROM
dbo.sysmail_allitems AS SA LEFT JOIN
dbo.sysmail_event_log AS SEL ON
SA.mailitem_id = SEL.mailitem_id
Where
SA.mailitem_id = @mailitem_id
Or you could do a job/report that checks a time range.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question