I just loaded a server. I did not put any mail clients on it except what server 2000 came with. Is there anyway to have sql server send me a mail message to my domain without using a mail client?
I think you need to have MAPI MAIL server or SMTP to send SQL Mail.
Just by installing SQL server.You wont be able to send SQL mail.But if it's ok for you,you can use net send to prompt your domain user.
So I need something like Exchange server running on the remote box? Any way around this? All I want is to get an e-mail here at the office if SQL Server crashes, or if one of my DTS packages fail.
(with the above you need SMTP services running on the same machine)
Try this creating this stored procedure. I put this in the master DB. This works for me, just make sure to change the email server accordingly. (This uses microsofts remote SMTP "Service", no local service or client is needed)
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference to the CDOSYS objects are at the following MSDN Web site:
-- This is to configure the Server Name or IP address.
-- Replace MailServerName by the name or IP of your SMTP Server.
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("
-- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
EXEC @hr = sp_OASetProperty @iMsg, 'TextBody', @Body
EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL
-- Sample error handling.
IF @hr <>0
select @hr
BEGIN
EXEC @hr = sp_OAGetErrorInfo NULL, @source OUT, @description OUT
IF @hr = 0
BEGIN
SELECT @output = ' Source: ' + @source
PRINT @output
SELECT @output = ' Description: ' + @description
PRINT @output
END
ELSE
BEGIN
PRINT ' sp_OAGetErrorInfo failed.'
RETURN
END
END
-- Do some error handling after each step if you need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
GO
although now the article seems to be missing without a trace from their servers. Maybe this threatens the sales of MS Exchange?
I enhanced the error handling by putting a label as follows:
...
-- Sample error handling.
OOPS:
IF @hr <>0
select @hr
...
I also added the ability to add attachments
optional parameter @attachment is the path to a file saved on the server:
...
-- Add attachments
if rtrim(@Attachment)<>''
EXEC @hr = sp_OAMethod @iMsg, 'AddAttachment', @returnval out, @Attachment
if @hr<>0 goto OOPS --error handling if file not found
...
also CC, etc
...
EXEC @hr = sp_OASetProperty @iMsg, 'CC', @CC
EXEC @hr = sp_OASetProperty @iMsg, 'BCC', @BCC
EXEC @hr = sp_OASetProperty @iMsg, 'ReplyTo', @ReplyTo
...
Ok. I found that I have SMTP loaded. It is running. NOw how do I get to it? Remember that I am a developer, not a systems' person. What is the name of my smtp server? The server's name?
Remember there is not any mail server on this stand alone server. It's a remote server off site. I don't care about getting mail there, just sending it from a web form, and from SQL server.
Try out this SP, this one is very simple. One note, notice that the @MailServer variable shows 'localhost' next to it? This is what you will be sending to this variable, if you decide to remove that value in the SP. When you designate that it will "look" localhost, the code will utilize your local SMTP service (hence the mail should send fine!). Sorry for all the confusion.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.