2016-04-20 8 views

Antwort

1

Here ist ein Blog, das den Prozess detailliert.

Im Folgenden finden Sie eine grobe Kopie des Blog-Inhalts, um diese Antwort zukunftssicher zu machen.

  1. Aktivieren Sie die Datenbank Mail gespeichert Procs:

    sp_configure 'show advanced options', 1; 
    GO 
    RECONFIGURE; 
    GO 
    sp_configure 'Database Mail XPs', 1; 
    GO 
    RECONFIGURE 
    GO 
    
  2. die sysmail Konto mit sysmail_add_account_sp erstellen:

    EXECUTE msdb.dbo.sysmail_add_account_sp 
    @account_name = 'MailTest', 
    @description = 'Sent Mail using MSDB', 
    @email_address = '[email protected]', 
    @display_name = 'umashankar', 
    @username='[email protected]', 
    @password='password', 
    @mailserver_name = 'mail.queryingsql.com' 
    
  3. das Datenbankprofil erstellen mit sysmail_add_profile_sp:

    EXECUTE msdb.dbo.sysmail_add_profile_sp 
    @profile_name = 'MailTest', 
    @description = 'Profile used to send mail' 
    
  4. das Konto zu dem Profil Karte mit sysmail_add_profileaccount_sp:

    EXECUTE msdb.dbo.sysmail_add_profileaccount_sp 
    @profile_name = 'MailTest', 
    @account_name = 'MailTest', 
    @sequence_number = 1 
    
  5. Erteilen einer Datenbank Haupt (Datenbankbenutzer oder Rolle), um das Datenbankprofil zu verwenden:

    EXECUTE msdb.dbo.sysmail_add_principalprofile_sp 
    @profile_name = 'MailTest', 
    @principal_name = 'public', 
    @is_default = 1 ; 
    
    --A principal_name of 'public' makes this profile a public profile, granting access to all principals in the database. 
    
  6. -Test mit sp_send_dbmail:

    exec msdb.dbo.sp_send_dbmail 
    @profile_name = 'MailTest', 
    @recipients = '[email protected]', 
    @subject = 'Mail Test', 
    @body = 'Mail Sent Successfully', 
    @body_format = 'text' 
    

Sie sollten auch die MSDN-Dokumentation für jede gespeicherte Prozedur nachschlagen, um sicherzustellen, dass Sie Ihr System ordnungsgemäß konfigurieren.

+0

Ich bin ein Anfänger, also kann ich Ihre Antwort nicht als richtig für jetzt markieren. –

0

Ich nehme an, Sie können es mit den gespeicherten Procs in MSDB einrichten. Ich habe das nicht versucht, aber vielleicht möchtest du es versuchen.

Blick auf ...

sysmail_add_account_sp 

... und es wird gespeichert Procs verwendet.

sysmail_add_account_sp MSDN documentation

+0

Vielen Dank für den Vorschlag –

0

standardmäßig der SQL Express nicht Datenbank Mail-Konfiguration über einen GUI-Assistenten nicht unterstützt, doch ist es möglich, sie durch Skripte zu konfigurieren.

Diese detailed instructions führen Sie.