How to auto send mai by using this function sp_send_dbmaill

Posted on 2008-11-17
Last Modified: 2012-05-05
I have the following:
can anyone explain what are these functions for (@profile_name ,@query @attach_query_result_as_file = 0,@query_result_header ,
@query_result_width ,
@exclude_query_output and
@query_result_separator)?  and I couldnt find this script when execute (msdb.dbo.sp_send_dbmai)l?  

I have the following:

EXEC msdb.dbo.sp_send_dbmail



@subject ='Subject',

@body_format = 'HTML',

@profile_name = 'Profile',

@query ='set nocount on; exec dataDayStrip 657,4,7; set nocount off;', 

@attach_query_result_as_file = 0,

@query_result_header = 1,

@query_result_width = 1000,

@exclude_query_output = 1,

@query_result_separator = ';'

Open in new window

Question by:risk-x
    LVL 25

    Expert Comment


    Author Comment

    After I try to execute the following code. There is a error message. what is this error message about?

    Msg 14636, Level 16, State 1, Procedure sp_send_dbmail, Line 95
    No global profile is configured. Specify a profile name in the @profile_name parameter.
    EXEC msdb.dbo.sp_send_dbmail @recipients='',
        @subject = 'fail download',
        @body = 'testing',
        @body_format = 'HTML' ;

    Open in new window

    LVL 25

    Accepted Solution

    follow link for more info

    [ @profile_name = ] 'profile_name'
    Is the name of the profile to send the message from. The profile_name is of type sysname, with a default of NULL. The profile_name must be the name of an existing Database Mail profile. When no profile_name is specified, sp_send_dbmail uses the default private profile for the current user. If the user does not have a default private profile, sp_send_dbmail uses the default public profile for the msdb database. If the user does not have a default private profile and there is no default public profile for the database, @profile_name must be specified.


    Author Closing Comment

    Thx for the explanation! you are really helpful......Thx

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
    INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now