VS 2003 - Count Rows In Excel E-mail Attachment?
Jan 4, 2007
I have a C# program that sends an e-mail with an Excel attachment. The Excel file is populated with the results of a SQL stored procedure before the e-mail program is executed. The entire process is in a DTS package (populate a temporary table, export the table to Excel, then send the e-mail). It is possible that the stored procedure will return no results, in which case the Excel file will not be populated.
I'd like to know whether it is possible (and if so, how) to add some code to my e-mail program that will count the number of populated rows in the Excel file and if that number is <2 (the header row will always be populated), to quit and not send the e-mail.
An alternative would be for the DTS package to terminate if the stored procedure returns 0 records.
Thanks!
View 3 Replies
ADVERTISEMENT
Mar 3, 2008
HI !
I need help to fix SSIS Send Mail Task Error.
I have a
Data Flow
Read from Sql Data base and then put the query result into excel file
(OLE DB Source --> Excel Destination)
Send Mail Task
Email excel file from the data flow
Control Flow :
Data Flow --> Send Mail Task
The package throws an error below. I tried to disable my antivirus because i thought it's throwing an error because of the antivirus.
But, it's still throwing the same error. If i tried to send email without attachment, it works just fine.
Is there anybody know how to fix this?
Progress: The SendMail task is initiated. - 0 percent complete
[Send Mail Task] Error: An error occurred with the following error message: "The operation has timed out.".
Progress: The SendMail task is completed. - 100 percent complete
Task Send Mail Task failed
View 3 Replies
View Related
Aug 12, 2015
I have below table in the snapshot, My task is to send the same output as a attachment in Excel to email. i used the below procedure
Â
EXEC [msdb]..sp_send_dbmailÂ
@profile_name='TSSSendMail',
@recipients='mymailID@gmail.com.com',
@subject='DB Mail',
@body='HI Team',
@execute_query_database = 'DbName',
@query = 'EXEC J16ReimbursementFortnightly1TO15 1',
@attach_query_result_as_file=1,
@query_attachment_filename = 'SummaryReimbursement.xls'
But I am not getting Proper Output, is seems like CSV Format, but i want it proper tabular format in Excel.
View 4 Replies
View Related
Sep 11, 2007
Hi,
I need to import an SQL string from MS Excel 2003 to SQL SERVER 2000.
The string I need to import is composed by 5 different several blocks and looks like:
Code Snippet
CommandLine01 = "USE mydb"
CommandLine02 = "SELECT Block ..."
CommandLine03 = "GO
ALTER TABLE Block...
GO"
CommandLine04 = "UPDATE Block..."
CommandLine05 = "SELECT Block..."
The detail of the SQL string is at:
http://forums.microsoft.com/msdn/showpost.aspx?postid=2093921&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1
I am trying to implement OJ's suggestion:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2117223&SiteID=1
to use multi - batch processing to import the string to SQL SERVER, something like:
Code Snippet
Dim SqlCnt, cmd1, cmd2, cmd3
'set the properties and open a connection
cmd1="use my_db"
cmd2="create table mytb"
cmd3="insert into mytb"
SqlCnt.execute cmd1
SqlCnt.Execute cmd2
SqlCnt.Execute cmd3
Below is the code (just partial) I have, and I need help to complete it.
Thanks in advance,
Aldo.
Code Snippet
Function TestConnection()
Dim ConnectionString As New ADODB.Connection
Dim RecordSet As New ADODB.RecordSet
ConnectionString = "Driver={SQL Server};Server=myServer;Database=myDBName;Uid=UserName;Pwd=Password"
ConnectionString.Open
CmdLine01 = " USE " & myDB
CmdLine02 = " SELECT ACCOUNTS.FULLNAME FROM ACCOUNTS" ...
CmdLine03 = "GO
ALTER TABLE Block...
GO"
CmdLine04 = "UPDATE Block..."
CmdLine05 = "SELECT Block..."
RecordSet.Open CmdLine01, ConnectionString
RecordSet.Open CmdLine02, ConnectionString
ConnectionString.Execute CmdLine01
ConnectionString.Execute CmdLine02
'Retrieve Field titles
For ColNr = 1 To RecordSet.Fields.Count
ActiveSheet.Cells(1, ColNr).Value = RecordSet.Fields(ColNr - 1).Name
Next
ActiveSheet.Cells(2, 1).CopyFromRecordset RecordSet
'Close ADO objects
RecordSet.Close
ConnectionString.Close
Set RecordSet = Nothing
Set ConnectionString = Nothing
End Function
View 7 Replies
View Related
Sep 19, 2001
I'm trying to use the xp_sendmail and include a txt file as an attachment.
I can't get the procedure to work with the attachment.....any help would be greatly appreciated. this is what I have been trying to get to work.....Thanks!! Scott
exec master.dbo.xp_sendmail
@recipients = 'xyz@email.com',
@query = 'SELECT * FROM ape_pt_temp',
@subject = 'SQL Server Report',
@message = 'file attached',
@attach_results = 'true', @width = 250
View 1 Replies
View Related
Mar 27, 2007
I wrote a procedure in Sql Server 2000 which sends an E-Mail to any E-Mail account. But I not able to send an attachment with the E-Mail. I dont have the code for attachment in the same procedure, as I searched on Google I not able to find out. Please help me for the same.
Waiting for your reply.
View 3 Replies
View Related
Feb 27, 2006
Hi,
I am using the following stored procedure to send a mail with attachment. But the mail is sent without the attachment. Can anyone help me?
CREATE PROCEDURE DBO.sp_Send_Mail_test(
@p_From as nvarchar(50),
@p_To as nvarchar(50),
@p_Subject as nvarchar(255),
@p_Body as varchar(1000),
@p_CC as text = null,
@p_BCC as text = null,
@p_Attachment varchar(500)=null
)
AS
Declare @Message int
Declare @hr int
Declare @source varchar(255)
Declare @description varchar(500)
EXEC @hr = sp_OACreate 'CDO.Message', @Message OUT
EXEC @hr = sp_OASetProperty @Message, 'From',@p_From
EXEC @hr = sp_OASetProperty @Message, 'To', @p_To
EXEC @hr = sp_OASetProperty @Message, 'Subject', @p_Subject
EXEC @hr = sp_OASetProperty @Message, 'TextBody', @p_Body
EXEC @hr = sp_OAMethod @Message, 'CDO.Message.Attachment.Update', Default, @p_Attachment
If @p_CC is not null
BEGIN
EXEC @hr = sp_OASetProperty @Message, 'CC',@p_CC
END
If @p_BCC is not null
BEGIN
EXEC @hr = sp_OASetProperty @Message, 'BCC',@p_BCC
END
EXEC @hr = sp_OAMethod @Message, 'Send', NULL
EXEC @hr = sp_OAGetErrorInfo NULL, @source OUT, @description out
EXEC @hr = sp_OADestroy @Message
IF @hr <> 0
BEGIN
SELECT hr=convert(varbinary(4),@hr), Source=@source, Description=@description
RETURN
END
Regards,
Bharathram G
View 1 Replies
View Related
Apr 22, 2004
Hi,
I am able to send normal mails from SQL Server with no attachments.
But when i am trying to send mail with an attachment i get following error.
Server: Msg 18025, Level 16, State 1, Line 0
xp_sendmail: failed with mail error 0x80004005
I am running SQL Server 2000 , SP3.
select @@version
---------------------------------
Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
exec master..xp_msver
------------------------------------------
Index Name Internal_Value Character_Value
------ -------------------------------- -------------- ------------------------------------------------------------------------------------------------------------------------
1 ProductName NULL Microsoft SQL Server
2 ProductVersion 524288 8.00.760
3 Language 1033 English (United States)
4 Platform NULL NT INTEL X86
5 Comments NULL NT INTEL X86
6 CompanyName NULL Microsoft Corporation
7 FileDescription NULL SQL Server Windows NT
8 FileVersion NULL 2000.080.0760.00
9 InternalName NULL SQLSERVR
10 LegalCopyright NULL © 1988-2003 Microsoft Corp. All rights reserved.
11 LegalTrademarks NULL Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation
12 OriginalFilename NULL SQLSERVR.EXE
13 PrivateBuild NULL NULL
14 SpecialBuild 49807360 NULL
15 WindowsVersion 143851525 5.0 (2195)
16 ProcessorCount 1 1
17 ProcessorActiveMask 1 00000001
18 ProcessorType 586 PROCESSOR_INTEL_PENTIUM
19 PhysicalMemory 254 254 (266850304)
20 Product ID NULL NULL
(20 row(s) affected)
Any help would be helpful.
Regards
Jay
View 2 Replies
View Related
Mar 27, 2008
Dear Gurus
I have got a requirement.
I need to send mail with an attachment.
for eg.
An employee has requested leave a mail should go to the person he is reporting to as a mail and with this mail
an attachment of the leave request should be sent.
When the person who recevies mail he opens the attahcment and apporves the leave request or rejects a return mail to go to all concerned.
View 3 Replies
View Related
Nov 16, 2015
While handling errors in a flat file I am routing the rows into the excel sheet to business for further processing. Â I need to send a mail attaching the excel sheet which contains the errored-out/In-Complete definitons. The problem is I need to send a mail if and only if there is at least one row in Excel sheet. How Can I count the rows exist in excel sheet? and send the rowcount to a variable and use that value of a variable to send a mail?
View 5 Replies
View Related
Mar 13, 2007
Hi All,
In my SSRS report there is a column with email field, when the user clicks on it -- it should open the outlook and in the attachment field there should be a screenshot of that report
i think anything i could do is only in the jump to url in the navigation tab......Please suggest me the solution or any other alternatives.
Thanks in advance for help
Warm Regards,
Chanduu.
View 1 Replies
View Related
Jul 16, 2007
I am able to use a variable filename in my send mail task as the message source when I specify variable as the message source type. But I would rather use the variable in the attachment e.g. @[User::filename].
When I do that, I get the message that the file doen't exist. How is it possible to specify a variable as the attachment?
Den
View 7 Replies
View Related
Mar 29, 2001
Ok i have a programmer who wants to send out the data from a table as an email attachment via sql mail without having to write a com component. Does any one know the procedures on how to do this (i.e stored procedures and triggers ect and anything else i need or should know).
Please dont answer this unless you have some genuine help as I dont want to post this every time someone comes up with a smart ass comment!
Thanks guys
View 1 Replies
View Related
Nov 30, 2007
Hiii,
I am delivering report in Excel format every Monday. I am also including link with that email.
sometime, it delivers excel sheet correct and sometime it just gives blank sheet in attachment and the strange thing is that We can see data through the included link, but not in excel attachment.
Any idea??
If any of you passed through this problem plzzz help me out...
View 1 Replies
View Related
Jun 25, 2007
Hi all
i using lookup error output to insert rows into table
Rows count rows has been inserted on the table 59,123,019 mill
table rows count 6,878,110 mill ............................
any ideas
View 6 Replies
View Related
Feb 17, 2012
i am using sp_send_dbmail to send Emails.how to send query result as an attachment with EXCEL Format.
View 1 Replies
View Related
Jan 2, 2014
Is there a way to export query results to an excel fie and add that file as an attachment in the email? All this has to be done using SQL query and it needs to be automated. My coworker tried using Openrowset and BCP, but it is not working.
View 3 Replies
View Related
Jan 19, 2007
Hello All,
Hopefully someone out there will have an idea as this is driving me nuts.
I want to send a dynamic files in attachment files ny send mail task that file name has change follow datetime.
I try to use the expression but I can't use it.
please tell me for this problem.
Any suggestions appreciated,
Thanks.
View 4 Replies
View Related
Nov 3, 2015
Here below is the perfect query i made which is working fine and giving me the sql output but just only need is how to convert to excel and automate the job scheduling so that it run on everyday and send the mail with attachment .
SELECT DN, cn, displayName, mail, objectClass, sAMAccountName, Company, givenName, sn
FROM
(
SELECT DN, cn, displayName, mail, objectClass, sAMAccountName, Company, givenName, sn, 1 [ordering] FROM alpha.dbo.DCADFeed
where sAMAccountName collate SQL_Latin1_General_CP1_CI_AS in
[Code] ....
View 4 Replies
View Related
Jan 2, 2008
hi,
i have one application in Microsoft excel 2003. but when i open this in Microsoft excel 2007 it gives me error saying that
error inintializing menu,
object variable or with block variable not set.
kindly guide me what i can do for this. i m not getting exactly what is happening.
thanks & regards,
Vishruti.
View 3 Replies
View Related
May 6, 2005
Wondering if there is a different way to setup mail because of Windows Server 2003 instead of Windows Server 2000? The server I'm being asked to get mail working on will have an exchange email account and I'm not familiar with setting this up. On my 2000 machine I had to use Outlook 2000 with option for Corporate or Workgroup an a POP email account. Any help is appreciated.
View 2 Replies
View Related
Jan 30, 2006
I've just installed and configured outlook 2003 with sql agent mail and I've come across a strange conundrum: messages from agent mail are not actually sent unless the outlook client is open, but the default mail folder is locked by agent when agent is started, thus preventing outlook 2003 from opening. If I try things the other way - opening the client and then configuring/restarting agent mail - then agent mail can't access the default mail folder because the client has it locked.
There doesn't seem to be any way to win here.
Anyone come across this issue and found a workaround?
View 4 Replies
View Related
Sep 16, 2005
Scenario:DBMS: SQL Server 2000OS: Windows Server 2003Goal:Enable SQLMAIL via Internet MailProblem:How do I set up the MAPI profile for the SQL Server service account?On Windows 2000 Server, I can use "Control Panel"/"Mail" tocreate a MAPI profile for the SQL Server service account, and thenreference that profile for SQLMAIL in SQL Server and SQL Server Agent.But on Windows Server 2003, there is no "Mail" applet in "Control Panel".How do I create a MAPI profile, for the SQL Server service account,on Windows Server 2003?
View 5 Replies
View Related
Mar 15, 2007
We have a DTS package that imports data from a client's Excel file. Previously our client was using Excel 2000, but recently they upgraded to Office 2003, and now suddenly when I try to view the transformation task properties I get a Jet Database Engine error: "External table is not in the expected format".
Everything else with the file appears the same (layout, formatting, etc.).
Any suggestions?
View 1 Replies
View Related
May 8, 2008
Hi guys and gals,
Since monitoring blocks on the server, I have noticed that when I have a whole lot of users thrown out of their apps, it's all because of one PC.
The program name is "Microsoft Office 2003". The user reckons that they haven't opened any Excel files that have any kind of link to the live database.
Is there any known problem that you are aware of where Excel can "remember" connection strings maybe from other files you have opened in the past and would that spuriously throw INSERT, UPDATE & SELECT statements to the database server and that then cause locks?
The idea seem ludicrous to me. I'm stumped.
View 2 Replies
View Related
Mar 20, 2007
I want to use the CopyFromRecordSet however I am using a stored procedure that returns a recordset. Here is the code, but the recordset never opens. I have commented out the Execute
Here is a code snip, any Ideas? TIA Mike
Dim Con1 As New ADODB.Connection
Dim Cmd1 As New ADODB.Command
Dim Rs As New ADODB.Recordset
Con1.Open
Cmd1.ActiveConnection = Con1
Cmd1.CommandType = adCmdText
Cmd1.CommandText = "MyStroredProc"
Cmd1.Execute
Rs.Open Cmd1
Worksheets("T1").Range("B1").CopyFromRecordset Rs
View 7 Replies
View Related
Feb 20, 2008
Hi,
When expoting data from excel to sql server table, using SSIS package, after exporting is done, how would i check source rows are equal to destination rows. If not to throw an error message.
How can we handle transactions in SSIS
1. when some error/something happens during export and the # of rows are not exported fully to destination, how to rollback the transaction in SSIS.
Any sort of help would be highly appreciated.
Thanks,
View 2 Replies
View Related
Feb 20, 2008
Hi,
When expoting data from excel to sql server table, using SSIS package, after exporting is done, how would i check source rows are equal to destination rows. If not to throw an error message.
Any sort of help would be highly appreciated.
Thanks,
View 1 Replies
View Related
Apr 6, 2006
Environment:
Running this code on my PC via VS 2005
.Net version 2.0.50727 on the server (shown in IIS)
Code is in ASP.NET 2.0 and is a VB.NET Console application
SSIS 2005
Problem & Info:
I am bringing in an Excel file. I need to first strip out any non-detail rows such as the breaks you see with totals and what not. I should in the end have only detail rows left before I start moving them into my SQL Table. I'm not sure how to first strip this information out in SSIS specfically how down to the right component and how to actually code the component to do this based on my Excel file here: http://www.webfound.net/excelfile.xls
Then, I assume I just use a Flat File Source coponent or something to actually take the columns in the Excel and split into an OLE DB Datasource to shove each column into a corresponding column in my SQL Server Table. I have used a Flat File Source in the past to do so with a comma delimited txt file but never tried with an Excel.
Desired Help:
How to perform
1) stripping out all undesired rows
2) importing each column into sql table
View 1 Replies
View Related
Mar 31, 2008
I want to export Excell 2003 to Sql Server 2005. I am having the following error while execute the query.
declare @SQL varchar(8000)
create table #temp(i int identity(1,1),SiteName varchar(100),SiteDescription varchar(5000),SiteURL varchar(500),CategoryName varchar(200))
set @SQL='Insert into #temp Select * From OPENROWSET (''Microsoft.Jet.OLEDB.4.0'',''Excel 8.0;Database=' +
'a.xls' +';HDR = YES;IMEX=0'',''SELECT * FROM [Sheet1$]'')'
exec (@SQL)
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
I need a solution urgently. help Pls
View 3 Replies
View Related
Dec 22, 2006
Hi,
I have encountered an error when attempt to open a report which is exported to Excel using SSRS2003. It looks like this:
Microsoft Office Excel File Repair Log
Errors were detected in file 'C:Documents and SettingsTocsonEIMy DocumentsRigidReports
ptRigidTransactionSummaryReport3.xls'
The following is a list of repairs:
Damage to the file was so extensive that repairs were not possible. Excel attempted to recover your formulas and values, but some data may have been lost or corrupted.
At first I thought it was because of the sheer bulk of the report since when I break down a month's report to every 5 days, it would export without error. So I thought that if I can break a whole report into several worksheets using page break, it might work. Unfortunately, although I did succeed in exporting the whole report into several worksheets, I still encounter the same error. Now I have no idea on what the root of the error is. Note that the same report can be exported in other formats and can be opened without error. Except for a case when I tried opening the same report exported in XML using Excel, an error which might be related to the error above occurs which says that there's an invalid unicode character in the xml file.
Any help in determining the root of the problem and a solution to it?
View 1 Replies
View Related
Jun 23, 2006
Hello,
how can I use SQL Svr 2005 Express as database engine in background through VBA code in Excel 2003?
I want to CREATE and DELETE tables and SELECT, INSERT and UPDATE data. Is it possible to use ADO or other database objects to get in contact with SQL Svr 2005 Express?
Thanks a lot.
Christian
View 4 Replies
View Related
Apr 13, 2008
Hi
I am trying to connect to SQL Express from Excel VBA using an user instance.
I have tried the following connection string:
Driver={SQL Native Client};Server=.SQLExpress;AttachDbFilename=full_path_to_mdf; Database=dbname;Trusted_Connection=Yes;
And I get the following error : Could not open new database 'dbname' CREATE DATABASE is aborted.
Any ideas on what I am doing wrong?
All I want is an Excel document to connect to a .mdf that is stored on a CD (The database will be readonly). I do not want the database to be stored on the users hard drive.
Many Thanks
MP
View 3 Replies
View Related