Re: E-Mail Nachricht an Operator



Manuel Kobloch wrote:
Hallo,

ich habe mal wieder ein Problem :). Man kann ja mit dem SQL Server
2008 bequem eine E-Mail an einen Operator versenden, sollte ein Paket
nicht durchlaufen. Bei mir funktioniert das leider nicht. Auch nicht
im SSIS. Denn komischerweise finde ich keine Möglichkeit das globale
Profil einzugeben, welches aber verlangt wird.

Wie folgt bin ich vor gegangen:

im MS SQL Server Management Studio
- Verwaltung / Datenbank-E-Mail
---> hier das Profil "SQL Mail" eingerichtet, das eine SMTP
Verbindung zu unserem Mail Server aufbaut (quasi der Absender)

- SQL Server-Agent / Operatoren
---> Hier Operator "Manuel Knobloch" mit E-Mail Adresse
eingefügt (quasi Empfänger)


Wenn ich jetzt ein Server Agent Auftrag oder ein SSIS Paket einrichte
und so einstelle, dass eine E-Mail verschickt wird, wenn der Auftrag
durchgelaufen ist, kommt leider nichts an oder es kommt eine
Fehlermeldung. Wenn ich ins Protokoll schaue, steht sowas, dass kein
globales Profil eingerichtet wurde.

Wenn ich den T-SQL anschaue (den man leider nicht bearbeiten kann),
sieht das so aus:

EXECUTE msdb.dbo.sp_notify_operator @name=N'Manuel
Knobloch',@subject=N'Test',@body=N'Testnachricht'

Wenn ich diese Zeile zu Testzwecken in eine neue Abfrage kopiere und
sie um den Eintrag "@profile_name=N'SQL EMail'" ergänze, funktioniert
der Befehl und eine E-Mail kommt an. Das sieht dann so aus.

EXECUTE msdb.dbo.sp_notify_operator @profile_name=N'SQL
EMail',@name=N'Michael Alisch',@subject=N'Test',@body=N'Testnachricht'

Also mein Problem ist jetzt, dass ich eigentlich je nach Bedarf bequem
per MS SQL Server Management Studio die Operatoren wechseln möchte
(dafür ist die GUI ja auch da). Habe ich irgendwie die Möglichkeit ein
globales Profil anzugeben? Denn sonst wäre diese Funktion doch völlig
sinnlos.

Hallo Manuel,
ich richte Mail nur noch per Skript ein. Danach sollte das auch mit den
Operatoren funktionieren. Also Skript ablaufen lassen und danach noch mal
durch die GUI kontrollieren. Erst dann funktioniert es auch tatsächlich.
Frag bitte nicht warum.
Für Dich reicht evtl., der Teil mit dem Standard-Profil, wenn der Rest schon
erledigt ist.

-- Aktiviere DB-E-Mail

exec sys.sp_configure 'show advanced options', '1'
RECONFIGURE

EXEC sys.sp_configure N'Database Mail XPs', N'1'
RECONFIGURE

-- Create a Database Mail account
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'SQLMail',
@description = 'Standard-Profil',
@email_address = 'SQLMail@meine_Domäne',
@replyto_address = 'dbadmins@meine_Domäne',
@display_name = 'SQLMail',
@mailserver_name = 'mein_Mailserver',
@use_default_credentials = 1


-- Create a Database Mail profile

EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'SQLMail',
@description = 'Standard-Profil für den Server' ;

-- Add the account to the profile

EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'SQLMail',
@account_name = 'SQLMail',
@sequence_number =1 ;


-- Große Attachments erlauben (15 MB) Standardwert ist 1000000 Byte = 1 MB
EXECUTE msdb.dbo.sysmail_configure_sp
'MaxFileSize', '15000000' ;


Einen schönen Tag noch,
Christoph
--
Microsoft SQL Server MVP
http://www.insidesql.org


.



Relevant Pages

  • Re: Dynamic SQL generation is not supported against a SelectCommand that does not return any base ta
    ... When you execute Update (for the first ... UpdateCommand etc. See my article on the CommandBuilder and why it should be ... SQL Server or MS Access. ... Code works fine with MS SQL Server. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Error running sql command
    ... If the commands are in a table on the server, I would create strings on the server and use SQL EXECUTE to execute them... ... I fetch a command from a table, process it and if command executes successfully I delete it form the queue. ... The basic problem with your code is that you are not using SQL Server as it should be used. ...
    (microsoft.public.dotnet.framework.adonet)
  • it all started on 5/27....
    ... individual DTS packages on SQL Server 2000 SP 4 that import and convert ... The SQL lives on a separate server than Pervasive. ... the same machine as SQL Server 2K SP 4. ... Now, if I execute the DTS packages individually on the server, all ...
    (microsoft.public.sqlserver.dts)
  • Re: Executing DTS from Code (correction)
    ... Granting execute permissions on these procs means that external Com objects can be called etc. ... If they run in-process and crash then bye-bye SQL Server. ... I moved the DTS package to the production server and>>> installed the application on the production server. ...
    (microsoft.public.sqlserver.dts)
  • Re: File Upload - Security Issues
    ... uploaded and the user could upload any or all of these in theory. ... There is no one product that can give you 100% security, ... > Code doesn't execute in local memory space unless remote user has rights ... > You don't have MS Office installed on the server. ...
    (microsoft.public.scripting.vbscript)