April 15, 2008 at 3:58 pm
Thanks in adavance,
I just created small procedures with sp_send_dbmail, when i try to send the data to the procedure it is giving error.
My procedure looks like this. When i try to use this is not working.
Create PROCEDURE SendNotification
@torecipients varchar(max),
@ccrecipient varchar(max),
@bccrecipient varchar(max),
@subject nvarchar(255),
@body nvarchar(max)
AS
BEGIN
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'ABC',
@recipients = @torecipients,
@body = @body,
@subject = @subject
END
The error i am getting is
Message
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2008-04-15T16:41:00). Exception Message: Cannot send mails to mail server. (Mailbox unavailable. The server response was: 5.7.1 Requested action not taken: message refused).
)
But when i try to execute the procedure directly like below, it is working perfect.
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'abc',
@recipients = 'abcd@abcd.com',
@body = 'This is from inside the procedure.',
@subject = 'Automated Success Message'
The service broker is enabled, and email is started.
Please suggest me how to rectify this.
April 16, 2008 at 8:26 am
I have something similar happen before when one or more of the variables was null. Can you check for that?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
April 16, 2008 at 8:52 am
Yes, exactly, probably one or more parameters must have a value, in other cases a parameter can be null.
April 16, 2008 at 11:40 am
When i try to send from the query analyzer it is working fine.
I figured the problem, when i try to access from my stored procedure, it is not saving the sent_account_id in the table msdb.dbo.sysmail_mailitems , this is the reason it is not sending the emails.
When i try to send email from query analyzer it is updating the default account id.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply