Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


A severe error occurred on the current command


A severe error occurred on the current command

Author
Message
anish.john
anish.john
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 3
When iam Running the Stored procedure there is an error occuring
"A severe error occurred on the current command"
this is my code..

this is using for sending mail to clients

if iam sending mail without attachment its working perfectly
but if i attach a file then that error occured...

please help me
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER PROCEDURE [dbo].[SSL_SEND_EMAIL]
@From as nvarchar(50),
@To as nvarchar(2000),
@Cc as varchar(2000),
@Subject as nvarchar(255),
@Body as text,
@Attachment as varchar(1000)
)
AS

-- Declare
SET NOCOUNT ON;
DECLARE @Server varchar(30)
SET @Server= (select Mast_Text from MasterSettings where Mast_Id=2)
DECLARE @message int
DECLARE @config int
DECLARE @hr int
DECLARE @src varchar(255), @desc varchar(255)

EXEC @hr = sp_OACreate 'CDO.Message', @message OUT -- create the message object
EXEC @hr = sp_OACreate 'CDO.Configuration', @config OUT -- create the configuration object

-- Configuration Object

EXEC @hr = sp_OASetProperty @config, 'Fields(cdoSendUsingMethod)', 'cdoSendUsingPort'
EXEC @hr = sp_OASetProperty @config, 'Fields(cdoSMTPServer)', @Server
EXEC @hr = sp_OASetProperty @config, 'Fields(cdoSMTPServerPort)', 25
EXEC @hr = sp_OASetProperty @config, 'Fields(cdoSMTPAuthenticate)', 'cdoAnonymous'
EXEC sp_OAMethod @config, 'Fields.Update'

-- Message Object

EXEC @hr = sp_OASetProperty @message, 'Configuration', @config
EXEC @hr = sp_OASetProperty @message, 'To', @To
EXEC @hr = sp_OASetProperty @message, 'Cc', @Cc
EXEC @hr = sp_OASetProperty @message, 'From', @From
EXEC @hr = sp_OASetProperty @message, 'Subject', @Subject
EXEC @hr = sp_OASetProperty @message, 'HTMLBody', @Body



if(isnull(@Attachment,'')<>'')
Begin
--EXEC @hr = sp_OAMethod @message, 'AddAttachment', NULL, @Attachment
End

EXEC @hr = sp_OAMethod @message, 'Send', NULL


---- Destroys the objects

EXEC @hr = sp_OADestroy @message
EXEC @hr = sp_OADestroy @config

-- Errorhandler

IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @message, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
SET NOCOUNT OFF;
END





if iam comment following part its work perfectly

if(isnull(@Attachment,'')<>'')
Begin
--EXEC @hr = sp_OAMethod @message, 'AddAttachment', NULL, @Attachment
End
************************************************
Note:--this attachment already created in the link server and iam fetching that file from there

when iam creating a file its work perfectly
but when iam fetching that file and send that error occuring
ALZDBA
ALZDBA
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 6974 Visits: 8839
So you see you would be better off using dbmail !
(better in sql2005 and nomore need for oa-stuff !!)

Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere w00t

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution" :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
JediSQL
JediSQL
Valued Member
Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)Valued Member (70 reputation)

Group: General Forum Members
Points: 70 Visits: 187
A major problem with dbmail is that you cannot specify the From address at run time; you have to set up a different profile for every From address you want to use.

Sincerely,
Daniel
Jack Corbett
  Jack Corbett
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11020 Visits: 14858
JediSQL (9/24/2013)
A major problem with dbmail is that you cannot specify the From address at run time; you have to set up a different profile for every From address you want to use.


Since this is a 2005 forum I'll assume that this is actually a 2005 server we are talking about so you are correct, @from_address was added as a parameter to sp_send_dbmail in 2008.

Still I would consider this an annoyance, not a major problem since there is a workaround. Especially in comparison to the sever error that is being caused by using sp_OA* in this case. So I would still recommend using sp_send_dbmail over sp_OA*



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search