Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Mail

Author  Topic 

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-15 : 01:22:16
Need some help here.

I created account for SQL mail to send mail for Job notifications etc using sql service account. I setup and configured XP Office outlook tested settings and all test worked fine
THIS CONFIGURED ACCOUNT IS POP TO INTERNET AND IS ALSO MY WORKSTATION EMAIL POP ACCOUNT WHERE I WISH TO RETRIEVE JON NOTIFICATIONS/OUTPUT.

I have a complicated couple of issues here

First issue

notifications will not work unless i am constantly logged into the sql box as the sql service/agent account. Also when the job does run I do get a net send notification to my workstation but do not get the notification of job success/ or the job related run stored proc on my workstation via email. I do however receive the successful job notification with the sqlservice email account on the sql box itself but not the results of the proc that i have setup with the job.


Shouldnt the job still run and notifications be sent out if i'm logged in to sql box as a diff user other than the sql service account?

Second Issue: Is I have a Proc configured for spaceused on my tables which should be sent via email when job succeeds and it does not work. The file i have for output however is populated. The only email i seem to be able to retrieve with sql mail setup is a job success notification from within the sqlservice profile on the sql box itself but this does me no good as you can see since i would like to be logged in to sql as admin and retrieve the email notifications via my workstation. Any ideas? Thanks




Keithc MCSE MCSA

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-06-15 : 08:37:21
Go In EM select your server and select Properties, Go to the Server setting tab and check the SQL Mail Settings. I have found that the SQL Mail settings can test out fine in support services but not be set under server properties causing failure.

Jim
Users <> Logic
Go to Top of Page

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-15 : 11:43:26
That was one of first steps I did to configure it. The job notifications work as long as the sql box is logged in as the sql service account. Prob is i like to login as Administrator on this box and if I do this then any job notifications will run still but not be sent out until the sqlservice account logs back in local to the server. I Think that when i'm logged in as Admin the service has no way of accessing the Mapi (Email) profile of the sqlservice account. I dunno I'm stumped on this one

Keithc MCSE MCSA
Go to Top of Page

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-15 : 12:03:18
I think I just found out why. I am using OUTLOOK 2002 and i just read that if using this Mapi client You have to keep the Outlook client open on the server at all times. Gonna hunt for outlook 2000 now, BTW thanks for the response

Keithc MCSE MCSA
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-06-15 : 18:03:51
Not sure if this is an option for you but I have never been able to figure out how this MAPI-stuff worked so I ripped and modified a procedure to use an ActiveX dll (www.aspemail.com)instead. Drawback is that the database needs to be able to access an emailserver but that's usually not a problem...let me know if you're interested.

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-06-15 : 18:29:59
Outlook 2000 will probably not work either. Try Outlook 98. It does not support the recent MS security 'enhancements'
Go to Top of Page

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-15 : 20:23:30
I like your suggestion with Outlook 98 but I have no way of getting it and it was pulled off net as a download about 4yrs ago. Also lumbago the reason I am wanting mail functionality in first place is so i can setup jobs that will execute say like an sproc that lists space_used for my tables and then email me that report so if aspemail can do that yes i'd be interested

Keithc MCSE MCSA
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-06-15 : 20:32:35
Yup, aspemail can do that as long as it is possible for you to install stuff on the db-server or can have somebody do it for you. Go to www.aspemail.com, download the prog and install it. Then try to run the procedure I have added at the bottom here. Just modify it to fit your needs, I've only added the most basic features as I only use it for error-reporting failed jobs and such. But it actually works quite well...all you have to do is to change @Mailserver to something that is accessible from your db-server. Good luck.

Procedure:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE sp_SMTPMail
@ToAddress varchar(100),
@FromAddress varchar(100),
@Subject varchar(200),
@Body varchar(8000)

AS
SET NOCOUNT ON
DECLARE
@object int,
@hr int,
@property varchar(255),
@return varchar(255),
@src varchar(255),
@desc varchar(255),
@Mailserver varchar(100)

SET @Mailserver = 'mymailserverip'

-- First, create the object.
EXEC @hr = sp_OACreate 'Persits.MailSender', @object OUT
IF @hr <> 0
BEGIN
-- Report any errors
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
GOTO END_ROUTINE
END
ELSE
-- An object is successfully created.
BEGIN
-- Set properties
EXEC @hr = sp_OASetProperty @object, 'Host', @Mailserver
IF @hr <> 0 GOTO CLEANUP
EXEC @hr = sp_OASetProperty @object, 'From', @FromAddress
IF @hr <> 0 GOTO CLEANUP
EXEC @hr = sp_OASetProperty @object, 'Subject', @Subject
IF @hr <> 0 GOTO CLEANUP
EXEC @hr = sp_OASetProperty @object, 'Body', @Body
IF @hr <> 0 GOTO CLEANUP

EXEC @hr = sp_OAMethod @object, 'AddAddress', NULL, @ToAddress
IF @hr <> 0 GOTO CLEANUP

EXEC @hr = sp_OAMethod @object, 'Send', NULL
GOTO CLEANUP

END

CLEANUP:
-- Check whether an error occurred.
IF @hr <> 0
BEGIN
-- Report the error.
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
END

-- Destroy the object.
BEGIN
EXEC @hr = sp_OADestroy @object
-- Check if an error occurred.
IF @hr <> 0
BEGIN
-- Report the error.
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
END
END
END_ROUTINE:
RETURN


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO


Go to Top of Page

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-15 : 22:06:49
Thanks alot Lumb, I'll be able to run everything. I'm running a couple sql servers in non-production trying to learn and do as much as I can. I have logging enabled from my firewall into SQL and it will be nice if this works so that I can get emails relative to sp_spaceused Procedure for my tables disk usage. Thanks again

Keithc MCSE MCSA
Go to Top of Page

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-15 : 22:35:41
Lumb Thanks a TON bud the proc works great. Aspemail installed without issues and now gonna give that a better looking into. Thanks again I appreciate it much.

Keithc MCSE MCSA
Go to Top of Page

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-15 : 23:09:44
Lumb had a question for you here maybe you or someone can help me out. What I am trying to do is use the procedure you listed above to some how call this procedure and send me the results in email.

exec sp_helptext usp_SpaceMonitor

AS

EXEC dbo.sp_spaceused

EXEC dbo.sp_spaceused 'Log1', 'True'

EXEC dbo.sp_spaceused 'Log2', 'True'

EXEC dbo.sp_spaceused 'Log3', 'True'


GO


Keithc MCSE MCSA
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-06-16 : 04:16:00
Umh...how did you do that again. I can't remember actually...I think you'd be better off posting a new topic about that actually...
Go to Top of Page
   

- Advertisement -