Results 1 to 2 of 2
  1. #1
    Join Date
    May 2013
    Posts
    8

    Unanswered: Get DBMail output

    With Query Anylyser, I am sending mails with DBMail successfully.
    Each time mail is sent, bottom half window messages tab shows

    "Mail (Id: 30242) queued."

    Is there any way to capture Mail (Id: 30242) and update the same in a table?

    Regards,

  2. #2
    Join Date
    Feb 2008
    Location
    Columbus, OH
    Posts
    26
    If I understand your post, you're using sp_send_dbmail to send emails. If this is the case the information you're sending is already captured in a table:

    Code:
    SELECT * FROM msdb.dbo.sysmail_sentitems

    Our table gets pretty busy, so we clean up anything older than a year


    Code:
    DECLARE @MailDate DATETIME
    SET @MailDate = DATEADD(year,-1,GETDATE())
    
    EXECUTE msdb.dbo.sysmail_delete_mailitems_sp
    @sent_before = @MailDate
    
    EXECUTE msdb.dbo.sysmail_delete_log_sp
    @logged_before = @MailDate
    Now that I think about it, I should be purging this to an archiving database instead of deleting it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •