I have been using a method that once I found on internet if now here at sqlservercentral and has helped me identifying certain elements and information on one or more DBs in my environment and notifying me via the DBMail separately ..
ALTER PROCEDURE [dbo].[USP_CollectDBInformation_Display]
@DBName nvarchar(32) = '_N/A'
SET NOCOUNT ON;
sum(filesizemb) as FilesizeMB,
sum(freespacemb)*100/sum(filesizemb) as FreeSpacePct,
datepart(qq, InputDate) TheQuarter
where filesizemb > 0 and
when '_N/A' then '%%'
else '%' + @DBName + '%'
group by servername,databasename, [Status], RecoveryMode, InputDate
and then the email of course
@profile_name = 'LocalServer'
,@recipients = 'JohnE.email@example.com'
,@query = ' your statement goes here '
,@Subject = 'DB Information'
,@Attach_query_result_as_file = 1;
Albeit, I like your method and definitely going to examine it in my test environment and I know that I am going to like it..