Database Mail Sends Test Mails Successfully, But Sp_send_dbmail Fails

Apr 15, 2008



Hi all,

I am having a few problems with Database Mail and wondered if anyone could assist. It sends test mails fine, but when I run the following script:

(I've changed my email address in this post to test@test.com they are accurate in the scripts.)


EXEC msdb.dbo.sp_send_dbmail

@profile_name = 'Test Mail',

@recipients = 'test@test.com',

@body = 'Sent by sp_send_dbmail',

@Subject = 'SQL Server Email Test Email';


It gives the following errors.

(from the above script)


mailitem_id = 16
profile_id = 2
recipients = test@test.com
copy_recipients = NULL
blind_copy_recipients = NULL
subject = SQL Server Email Test Email
body = Sent by sp_send_dbmail
body_format = TEXT
importance = NORMAL
sensitivity = NORMAL
file_attachments = NULL
attachment_encoding = MIME
query = NULL
execute_query_database = NULL
attach_query_result_as_file = 0
query_result_header = 1
query_result_width = 256
query_result_separator =
exclude_query_output = 0
append_query_error = 0
send_request_date = 2008-04-15 10:50:03.827
send_request_user = COMPANYTest.Test
sent_account_id = NULL
sent_status = failed
sent_date = 2008-04-15 10:50:04.000
last_mod_date = 2008-04-15 10:50:04.513
last_mod_user = sa


(from the test mail)


mailitem_id = 11
profile_id = 2
recipients = test@test.com
copy_recipients = NULL
blind_copy_recipients = NULL
subject = Database Mail Test
body = This is a test e-mail sent from Database Mail on UKDEVSQL1
body_format = TEXT
importance = NORMAL
sensitivity = NORMAL
file_attachments = NULL
attachment_encoding = MIME
query = NULL
execute_query_database = NULL
attach_query_result_as_file = 0
query_result_header = 1
query_result_width = 256
query_result_separator =
exclude_query_output = 0
append_query_error = 0
send_request_date = 2008-04-15 09:51:46.530
send_request_user = COMPANYTest.Test
sent_account_id = 4
sent_status = sent
sent_date = 2008-04-15 09:51:46.000
last_mod_date = 2008-04-15 09:51:46.610
last_mod_user = sa


sysmail_event_log gives this error for mail item 16 (the scripted email):

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 4 (2008-04-15T10:11:41). Exception Message: Cannot send mails to mail server. (Mailbox unavailable. The server response was: 5.7.1 Requested action not taken: message refused). )

View 2 Replies


ADVERTISEMENT

DTS-Package Sends Mail And Files Before The Job Finishes

Jan 11, 2008

I have a package which truncates files, fills them with data andshould send a mail with the files as attachment when it finishesrunning. In between, when the task is still running mail is sent withempty files. When I take a look at the directory (at the end of thetask), where the files are created I find out that the files are notempty.(e.g. in task: doA->doB->doC->SendMail. But instead of waiting tilldoB->doC finishes, it does the following: doA->SendMail ... may bebecause doB takes long.)Can I indicate anywhere that it should delay the mail until at the endof the task?Thanks in advance.Harp

View 1 Replies View Related

Help With Mail That Send Mail When Database Bakcup Fails

Sep 1, 2006

Hello

I have got a script which gives the mail to the dba mail box when database backup fails.

In the script I want to make a change so that I get the particular database name , on what ever database i implement.

Can you tell me some suggestions.

The script I am using is :



use master
go
alter PROCEDURE dbo.SendMail
@to VARCHAR(255),
@subject VARCHAR(255),
@message VARCHAR(8000)
AS
BEGIN
SET NOCOUNT ON;
DECLARE
@rv INT,
@from VARCHAR(64),
@server VARCHAR(255);
SELECT
@from = 'testsql2000@is.depaul.edu',
@server = 'smtp.depaul.edu';


select @message = @message + char(13) + Char(13) + @@servername + '-'+ db_name()+ '-' + 'Backup Status Failed' + Char(13)

EXEC @rv = dbo.xp_smtp_sendmail
@to = @to,
@from = @from,
@message = @message,
@subject = @subject,
@server = @server;
END
GO




--- After the above script is run the following should be given in the 2nd step when
--- the backup jobs are scheduled ------

exec master.dbo.sendmail
@to = 'dvaddi@depaul.edu',
@subject =' Test sqlserver 2000',
@message = '' ;




Thanks

View 4 Replies View Related

Database Mail - Send Test Email

Nov 23, 2006

i've got a brand new server and just installed SQL 2005.

when i try to send a test email, i get the following error message:

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 5 (2006-11-23T11:49:34). Exception Message: Could not connect to mail server. (No connection could be made because the target machine actively refused it). )

I have checked all items from troubleshoot and eveything is ok...any help ?

thanks



View 2 Replies View Related

Xp_sendmail Fails But Alert System Sends Email Notification.

Nov 30, 2004

I receive the following error when trying to invoke xp_sendmail 'xp_sendmail: failed with mail error 0x80070005'. However, for alert notifications the email works fine. SQL is using an alias account to send mail. This account doesn't have any funny characters. Any ideas why the alert system works but xp_sendmail does not? The invokation of xp_sendmail is being done by SA.

Thanks.

View 6 Replies View Related

Using ASP Mail To Send Mails From MSSQL 2000 Server

Mar 13, 2004

Hello,
I am using a script to send mails from MSSQL 2000 server. The script is trying to use the ASPMail object is located within a SQL Job or DTS package in the SQL database. It is not being run through an ASP page. The ASPMail object works fine if running in an ASP page running on win2003 server. It DOES NOT work when trying to create the object within SQL ActiveX VB script running on mssql server. If I am using this script in a job and use Microsoft's Enterprise Manager it only tells me that the job failed. If I try to use this script in a DTS package I get the error: 'Can not create object ("SMTPsvg.Mailer"). If I use a third database manager I get the following error: 'Execute permission denied on object xp_ServiceControl database' Please let me know what is causing this and how to fix it. The script goes as below
'*************************************************
' Visual Basic ActiveX Script
'*************************************************
Dim Mailer
Set Mailer = CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "Webmaster"
Mailer.FromAddress = "webmaster@domainname.com"
Mailer.RemoteHost = "mail.domainname.com"
Mailer.AddRecipient "user", "mailid@domainname.com"
Mailer.Subject = "Test ASP Mail"
Mailer.BodyText = "Test"
x = Mailer.SendMail
Set Mailer = Nothing
Any help is appreciated
Regards

View 3 Replies View Related

Cannot Send Mails To Mail Server (The Operation Has Timed Out)

Apr 30, 2013

I have configured database mail in sql server 2008 r2 on my local machine.

While testing I have observed that some of mails are not getting triggered.

Log file shows following message-

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 7 (2013-04-30T10:23:57).

Exception Message: Cannot send mails to mail server. (The operation has timed out.)

I have written on SP for sending mails which sends 94 mail to different ail address out of which only 35 are getting delivered.

View 7 Replies View Related

Sp_send_dbmail-Mail Not Sent - Remote Certificate

Oct 17, 2007

When i use sp_send_dbmail stored procedure inside a Execute SQL task,the task is executed successfully.

But when i look in to 'Database Mail Log', it says

"The mail could not be sent to the recepient because of the mail server failure. Exception message: cannot send mails to mail server(The remote certificate is invalid according to the validation procedure)

Please let me know what can be the issue.

View 2 Replies View Related

Sp_send_dbmail Mail Queued. Message

May 2, 2006

I have an After Update Trigger specified on a database table to notify specific users via email when certain customer values are modified. (This is a HACK / Workaround for functionality that doesn't exsist in the product.)

I had be using xp_sendmail without a problem. I recently upgraded the database server to SQL2005 and wanted to try sp_send_dbmail. (I was interested in the asynch and the non-MAPI nature of Database Mail.)

This is the new code:


EXEC @retval = msdb.dbo.sp_send_dbmail


@recipients = @rec,

@blind_copy_recipients = @bcc,

@subject = 'Important Customer Information Change',

@body = @body

This is the old code:


EXEC @retval = master.dbo.xp_sendmail


@recipients = @rec,

@blind_copy_recipients = @bcc,

@subject = 'Important Customer Information Change',

@message = @body

The problem now is that the application reports an update failure because the sp_send_dbmail return the message "Mail Queued."

I don't know if there's a way to suppress this message or not. Or some other way to indicate that "all is well" even though the stored procedure returned a message.

Thanks in advance.

View 6 Replies View Related

SQL 2012 :: Database Mail - Test Email Works But Jobs Won't Send Out Notifications

Oct 19, 2015

I am trying to send out notifications when jobs complete (fail or succeed). I have database mail working fine on my DEV server, but I am having issues with it on my PROD server. I am currently having people look into if McAfee may be blocking it.

I am able to send out a test email from SSMS>Management>Database Mail, but when I set a Notification for a job, the job will complete and in the history, it will say "NOTE: Failed to notify 'User' via email."

I have created an Operator and set up Profiles and Accounts, just as I did on my DEV server.

View 2 Replies View Related

Unable To Send Test Mail From DB Mail

Jul 29, 2013

NOT ABLE TO SEND TEST MAIL FROM DB MAIL...The mail could not be sent to the recipients because of the mail server failure. . Exception Message: Cannot send mails to mail server. (Failure sending mail.).Exception Message: Cannot send mails to mail server. (Failure sending mail.).

View 4 Replies View Related

Not Able To Send Test Mail From DB Mail

Jul 29, 2013

NOT ABLE TO SEND TEST MAIL FROM DB MAIL///The mail could not be sent to the recipients because of the mail server failure. . Exception Message: Cannot send mails to mail server. (Failure sending mail.).Exception Message: Cannot send mails to mail server. (Failure sending mail.).

View 3 Replies View Related

DB Engine :: Replicate A Master Test Database To 100 Test Environments?

Oct 12, 2015

We are setting up a test lab environment with 100 machines.  We want one master testing db that gets replicated to each to run scripted application tests nightly.  

My goal is to minimize the amount of work to move this thing to each of the 100 test machines.  I am wondering if we need to even have the sql local and invest in a monster db server with 100 copies of the db we restore and each test machine point to their own db on that server, or if I should use db mirroring or something to get the master test db to each of those machines instead.

View 6 Replies View Related

Test For SQL Mail Session Started

Feb 27, 2001

I call a stored proc from an ASP page that eventually makes a call to xp_sendmail to email a confirmation back to our visitor. It all works fine as long as the Exchange Server hasn't crashed and therefore, rendered the SQL Mail session dead. Unfortunately, when this happens (which has been all too often recently), the web visitor gets the following message:

Number: -2147217900

Description: [Microsoft][ODBC SQL Server Driver][SQL Server]SQL Mail session is not started.

SQLState: 37000

Native Error: 17966

Is there a way I can check for this in the stored proc that calls xp_sendmail so I could still return to the ASP page and prevent the web visitor from seeing this error.

I've searched high and low to no avail.

Thanks,
Laura Stamps

View 1 Replies View Related

SQL Server Admin 2014 :: Database Mail Fails At Email Server Alert

Apr 23, 2015

We recently had a problem with DB Mail. SQL jobs that sends an email succeeded but the email in the job fail to sent. There was a problem with the email server. The error is included. We fixed the problem with the email server. How can I get an alert when a DB Mail email fails send?

Date4/23/2015 10:01:06 AM
LogDatabase Mail (Database Mail Log)

Log ID5907
Process ID13204
Mail Item ID5702
Last Modified4/23/2015 10:01:06 AM
Last Modified Bysa

Message
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2015-04-23T10:01:06). Exception Message: Cannot send mails to mail server. (Insufficient system storage. The server response was: 4.3.1 Unable to accept message because the server is out of disk space.).
)

View 2 Replies View Related

Instead Of Trigger - Works In Mgment Console But Fails In Live Test

Feb 4, 2008

Hi, I wasn't sure if this was the correct place for this question since it involves both T-SQL and ODBC but i thought I would start here. A little system information to start. I'm using SQL 2005 on a Windows 2003 server. An application is connection to my database through ODBC and adds records to a table one at a time (no batches).


I have an Instead of Trigger created on a table that tests for the existence of a valid foriegn key. If the key doesn't exist in the related table I want to insert the record into a "bad records" table.

My trigger works perfectly when I add a bogus record to the table directly in the SQL Management Console table view or thorugh an insert query. However, when I try a live test with an application connected via ODBC that is adding records to the table the trigger fails to catch the errors and will not update the "bad records" table. If a record is legitmate (i.e. has a valid foreign key) then the final bit of trigger code fires without a problem.

Does anyone know of a problem with Instead Of Triggers working on multiple tables when connection through ODBC? It just seems weird that the trigger works perfectly in one situation but then doesn't work in another.

Thanks and advance for any help you can give.

-Will

View 1 Replies View Related

Xp_sendmail: Failed With Mail Error 0x80040111 It Works Fine When You Do A Test From Enterprise Manager

Sep 12, 2007



Hello I am receiving the dreaded mail error listed above. I can send out a test E-mail from Enterprise Manager to operators, but I cannot run this Transact query:

EXEC master.dbo.xp_sendmail @RECIPIENTS = araz***@***.com(removed email address),
@SUBJECT = 'test'

I receive:
Server: Msg 18025, Level 16, State 1, Line 0
xp_sendmail: failed with mail error 0x80040111



I have stopped/restarted the SQL SERVER AGENT but haven't done much else as I haven't been able to.

Should it work through transact SQL if the test email works from Enterprise Manager?

This is SQL 2000 SP4 running on Win2K in the domain. Thank you.

View 8 Replies View Related

SQL Mail Fails To Start

Jun 25, 2001

Hi,
My SQL Mail fails to Start. I am using Outlook Express as my mail client. I am not sure why it does not work in one of the servers when it works fine in another SQL Server. Any ideas. Help Appreciated.

Thanks,
Cynthia

View 2 Replies View Related

DTS: Did Not Invoke SQL Mail When DTS Fails

Dec 6, 2000

Hi!

I have developed DTS package for various tasks and scheduled to run some time. I have included SQL Mail task to notify me for each process when it fails. The questions is, When I open the package and execute from the menu, it works and it notifies me through SQL Mail task when it fails but when DTS package invokes at scheduled time and it got failed but it did not notify me that process in between has failed. It seems like SQL Mail task does not work when i schedule the package. Is there any one did come across this situation? or is there any way to resolve this issue? Any help would be appreciated!

Thanks,
Mohana

View 1 Replies View Related

E-Mail User When StoredProc Fails

Jun 8, 2004

Hi,

I want to e-mail a user when a Stored Proc fails, what is the best way to do this? I was going to create a DTS package or is this too complicated?

Also, the Stored Proc inserts data from one table to another, I would like to use Transactions so that if this fails it rolls back to where it was, I'm not sure of the best way to go about this. Could anyone possibly point me in the right direction? Here's a copy of some of the stored procedure to give an idea of what I am doing:

-- insert data into proper tables with extract date added
INSERT INTO tbl_Surgery
SELECT
SurgeryKey,
GETDATE(),
ClinicianCode,
StartTime,
SessionGroup,
[Description],
SurgeryName,
Deleted,
PremisesKey,
@practiceCode--SUBSTRING(SurgeryKey,PATINDEX('%.%',SurgeryKey)+1, 5)
FROM tbl_SurgeryIn

INSERT INTO tbl_SurgerySlot
SELECT
SurgerySlotKey,
GETDATE(),
SurgeryKey,
Length,
Deleted,
StartTime,
RestrictionDays,
Label,
IsRestricted,
@practiceCode
FROM tbl_SurgerySlotIn

INSERT INTO tbl_Appointment
SELECT
AppointmentKey,
GETDATE(),
SurgerySlotKey,
PatientKey,
Cancelled,
Continuation,
Deleted,
Reason,
DateMade
FROM tbl_AppointmentIn

-- empty input tables
DELETE FROM tbl_SurgeryIn
DELETE FROM tbl_SurgerySlotIn
DELETE FROM tbl_AppointmentIn

Any help would me very much appreciated,

Thanks

View 3 Replies View Related

SMTP Database Mail Showing Error While Sending Mail

Mar 7, 2007

Lokendra writes "I have configured the Database mail profile and account in Sql Server 2005 but the mail is not sending and showing the following error message:

Error,235,The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2007-03-05T15:16:07). Exception Message: Cannot send mails to mail server. (Mailbox name not allowed. The server response was: Sorry<c/> that domain isn't in my list of allowed rcpthosts.).
),3000,90,,3/5/2007 3:16:07 PM,sa


but while in the same mail set up in previous instance of sql server 2005 the message was sending very well. After installing new instance of sql server 2005 the problem is arising.


Anybody can tell me that what I can do so that i can send mail using the SMTP databasemail account."

View 1 Replies View Related

Database Mail With Yahoo Business Mail Server

Feb 20, 2008

Hi all....

Our company use yahoo business mail server for our corporate mails. I know that I can configure database mail with SMTP. But when I try to configure database mail account with yahoo bizmail, I cannot do that. It gets configured but when I test it it doesn't send any mails. Do I need to have any special condiguration for this. SMTP address is smtp.bizmail.yahoo.com. Also I have specified the Authentication using my user name and password. Please help

Thanks

Rajesh

View 10 Replies View Related

Problem With Sending Mail Via Database Mail

Mar 9, 2007

Hi every body


I want to send a simple mail using DATABASE MAIL feature in SQL SERVER 2005.

I've defined a public profile.
I've enabled Database Mail stored procedures through the Surface Area Configuration .

but   I can't send a mail with sp_send_dbmail stored procedure in 'msdb' database .


when I execute sp_send_dbmail in the Managment Studio  the message is
"Mail queued"  but the mail is not sent.

Could it be related to Service Broker?Because  the Surface Area Configuration indicates:'this inctance does not have a Service Broker endpoint'.If so, how should I make an endpoint?

here is the log file after executing sp_send_dbmail:


1)  "DatabaseMail process is started"

2)   "The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2007-03-08T00:49:29). Exception Message: Could not connect to mail server. (No connection could be made because the target machine actively refused it)."

 The DatabaseMail90.exe is triggred ,so the mail is transfered to the mail queue but  DatabaseMail90.exe couldn't give the mail to SMTP server.The promlem is what should I do to make DatabaseMail90.exe able to connect to  the server?



please help me.

POUYAN

View 21 Replies View Related

MS Sends Out Wrong CD

Mar 18, 1999

I began installing SQL Server 7.0 the other day on a standard NT Server. When I got to the installation options, Enterprise Edition was the only server option. It wouldn't install on standard NT. Nothing on the box, in the box, or printed on the cd indicated that it was the Enterprise Version. The error message says something about not being able to install on this server from this CD.

We called MS and they did admit to sending an unknown number of CD's out with the wrong setup. I just thought I would pass that on to those of you who might be questioning your own sanity.

Good luck getting the replacement copy. They are telling us that it will be 4+ weeks before they overnight our copy to us. I won't even try to figure out why it would take that long to get a copy. Let us all know if any of you have run into this. I would like to see how common this is.

View 1 Replies View Related

Which Process Sends Out Email?

Jan 31, 2008

Hi all,

I have several DTSX packages which send out report files by mail. For security purposes, the SMTP server can only be reached from specified IP addresses, from specified processes, with specified sender address. I know all this information, except the process name that sends out the emails in a DTSX package. So my question is, what process can be identified as the one that sends out the email?

Thx!!!

View 3 Replies View Related

Subscription Sends 2 Emails

Jan 23, 2007

We have SQL server 2005 Reporting Services SP1. In Report Manager I have a shared subscription that runs every hour between 8am and 6pm (I created the shared subscription in Report Manager, then modified it in Sql Server Management Studio to run the hours I wanted). I have a second shared schedule that runs Tuesday and Friday at 7am. For 2 separate report subscriptions - one uses the hourly schedule and the other uses the 2-day schedule, the first time they run during the day it sends 2 email - after that it sends only 1 email, as it should. I created a subscription to email a report when the report content is refreshed from a report snapshot. In Properties...Execution, I selected to render this report from a report execution snapshot, and selected my shared schedule. For the History property I have selected Allow report history to be created manually and Store all report execution snapshots in history; I am not using a schedule to add snapshots to report history in the History property.

When I look at the job in Sql Server Management Studio, it has only ran once each hour. When I look at the snapshot history, there is only one record for each hour. Why is the first scheduled instance sent twice instead of once?

View 8 Replies View Related

Package Executes On Test Database But Not In Production Database

Aug 24, 2006

hi!

I am able to run the package successfuly in test database. but not in production database. It throughs up error saying

Description: Unable to load the package as XML because of package does not have a valid XML format. A specific XML parser error will be posted.
Description: Failed to open package file "D:\TAHOE\APPS\SSISPackages\Integration Services Packages\ArchiveMain.dtsx" due to error 0x80070015 "The device is not ready.". This happens when loading a package and the file cannot be opened or loaded c
orrectly into the XML document. This can be the result of either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.
End Error
Could not load package "D:\TAHOE\APPS\SSISPackages\Integration Services Packages\ArchiveMain.dtsx" because of error 0xC0011002.
Description: Failed to open package file "D:\TAHOE\APPS\SSISPackages\Integration Services Packages\ArchiveMain.dtsx" due to error 0x80070015 "The device is not ready.". This happens when loading a package and the file cannot be opened or loaded corr
ectly into the XML document. This can be the result of either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.

what is the problem here....

JAs

View 3 Replies View Related

Creating A Trigger That Sends An Email

Jul 26, 2000

Can anyone assist me?
I am trying to create a trigger within our local database that will allow me submit an email to a local exchange server. Its an internal email that our company has created for responses by candidates when the original stored procedure meets a condition of TRUE.

Is SQL 7.0 capable of sending emails to a specified address through a Trigger? I was told it could but have yet to come across any documentation backing this up.

Would anyone know the generic syntax I can use to create such a trigger?

Any suggestions would be appreciated.

Thanks in advance,
Claude Johnson
cjohnson@staffmentor.net

View 3 Replies View Related

In Debug OnError Sends Email But Does Not Finish

Apr 26, 2007

Hi,

I've setup the option to mail the error to a person. When the option is on I get the error message by mail but the package does not finish (eg. the failing task does not become red and the output windows never says anything about the error) - if I set the option to off the task fails as expected.

Is there something I havn't set up correctly?

Regards
Simon

View 5 Replies View Related

Hi, Please Help Me W/ Fetch Cursor Querying, This Sends Email Automatically

Dec 18, 2007

create proc emailnew

as
declare @From varchar(8000)
declare @Subject varchar(8000)
declare @Body varchar(4000)
declare @smtp varchar(8000)
declare @counter int, @tbl varchar(8000)
Declare @MailID int
Declare @hr int
Declare @To varchar(8000)
Declare @tblquery varchar(8000)
declare @id int, @deptemail varchar(8000), @tmpmth varchar(8000), @usedb varchar(8000)
set @from = 'name@mail.com'
set @subject = 'testheader'
set @body = 'testing successful'
set @smtp = 'smtp.com'

--=========================================================================
--============================ get database name =======================
IF (LEN(MONTH(GETDATE())) = 1)
BEGIN
Set @TmpMth = '0' + CAST(MONTH(GETDATE()) AS varchar(2)) --01
END
ELSE
BEGIN
Set @TmpMth = CAST(MONTH(GETDATE()) AS varchar(2)) --12
END
SET @UseDB = 'DATA' + CAST(YEAR(GETDATE()) AS varchar(4)) + @TmpMth --aia_DATA200712
--===================================================================
--============================ get table number =======================
set @counter = 1
while @counter >= 59
begin
IF (LEN(@counter) = 1)
BEGIN
Set @Tbl = '0' + @counter --01
END
ELSE
BEGIN
Set @Tbl = @counter --12
END

--=========================check if table being created exists
IF EXISTS (SELECT 1
FROM information_schema.schemata
WHERE catalog_name = 'temptable')
GOTO table_1
--=================================== get all email accounts =====================
set @tblquery = '
select ID, Email
INTO temptable
FROM
(
select distinct d.id, d.email from tt32_aia.dbo.department d right outer join tt32_aia.dbo.extension e ON (e.parentid = d.id) right outer join
' + @usedb + '.dbo.other' + @tbl + ' data ON (e.extn = data.extn) where callclass = '''' or callclass is null
UNION ALL select distinct d.id, d.email from tt32_aia.dbo.department d right outer join tt32_aia.dbo.extension e ON (e.parentid = d.id) right outer join
' + @usedb + '.dbo.inward' + @tbl + ' data ON (e.extn = data.extn) where callclass = '''' or callclass is null
UNION ALL select distinct d.id, d.email from tt32_aia.dbo.department d right outer join tt32_aia.dbo.extension e ON (e.parentid = d.id) right outer join
' + @usedb + '.dbo.local' + @tbl + ' data ON (e.extn = data.extn) where callclass = '''' or callclass is null
UNION ALL select distinct d.id, d.email from tt32_aia.dbo.department d right outer join tt32_aia.dbo.extension e ON (e.parentid = d.id) right outer join
' + @usedb + '.dbo.other' + @tbl + ' data ON (e.extn = data.extn) where callclass = '''' or callclass is null
)data
DECLARE deptemail_cursor CURSOR FOR select id, email
from temptable where id is not null
'

--=============================================================================
--====just above you can see the cursor.. below is sending the emails
--======================================================================

exec(@tblquery)


OPEN deptemail_cursor


FETCH NEXT FROM deptemail_cursor INTO @id, @deptemail

WHILE @@FETCH_STATUS = 0
BEGIN
--If LEN(@deptemail) > 0
--BEGIN
set @to = @deptemail
EXEC @hr = sp_OACreate 'CDo.message', @MailID OUT --CDo.message |CDONTS.NewMail <-- different mail server
EXEC @hr = sp_OASetProperty @MailID ,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'
EXEC @hr = sp_OASetProperty @MailID ,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value', @smtp
EXEC @hr = sp_OASetProperty @MailID , 'From', @From
EXEC @hr = sp_OASetProperty @MailID , 'HTMLBody', @Body
EXEC @hr = sp_OASetProperty @MailID , 'Subject', @Subject
EXEC @hr = sp_OASetProperty @MailID , 'To', @to
EXEC @hr = sp_OAMethod @MailID , 'Send', NULL
EXEC @hr = sp_OADestroy @MailID
--END
FETCH NEXT FROM deptemail_cursor INTO @id, @deptemail
END

CLOSE deptemail_cursor
DEALLOCATE deptemail_cursor

Table_1:
drop table temptable
return


set @counter = @counter + 1

end




this is suppose to send email automatically to every email account that it will get from all the tables (around 250 tables).
the problem is its not sending, but if i try to take my code outside of the "SET @COUNTER = @COUNTER + 1 END" and close the if statement above, i can produce the correct result.. i'm thinking maybe its the positioning? but, there could be some overhauling needed to do with this.. sorry for posting the sp. sorry for the trouble.. please help me

View 2 Replies View Related

Unit Testing For SSIS - To Test Or Not To Test?

Oct 17, 2006

Now that we have a good programming model in SSIS - the question is whether to write automated unit tests for your packages, and would it generally be a good idea for packages?

Also - if yes to write tests - then where to find more informations regarding How to accomplish that?

View 1 Replies View Related

How To Test SSis Package And What Are The Things I Need To Test It ?

Nov 27, 2007



hi every one,
i need to test SSIS pacakge which will import data from different database where record count is around 5 millions.
iam planning to test it through c# code as well as manually also.
SSIS source : consist of 7 tables
SSIS destination :consist of 7 tables
Using c# code iam trying to run ssis package through batch file.
i am putting expected rowcount, column count in an excel file and comparing same with destination tables by writing query implementing ADO.Net concept.
am i going right way ,can any one suggest best and productive way to test the ssis package .
what are the other things i need to test it.
do any one can add test cases to it.






S.No

Test Case


1

Verify all the tables have been imported.



2

Verify all the rows in each table have been imported.



3

Verify all the columns specified in source query for each table have been imported


4

Verify all the data has been received without any truncation for each column.



5

Verify the schema at source and destination



6

Verify the time taken /speed for data transfer


7

Fields truncated due to difference in length of the field at destination.
Regards
Arif shareef

View 9 Replies View Related

Best Way To Test To See If The Database Is Running?

Aug 7, 2007

Hello all-I need to check to see if the database is running before I begin all sorts of processing and figured I would do something like this.  Any better ways to do this?  I want to check to see if the db is up and running and also check to make sure I can connect to it.
Private Function DatabaseRunning() As Boolean
'Checks to see if the database is up and running.Dim objDataConnection As SqlConnection = New SqlConnection(ConnectionString)
Try
objDataConnection.Open()Catch ex As Exception
Return False
End Try
objDataConnection.Close()
Return True
End Function

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved