I am using Windows 2003 Server Standard ans MSSql 2000 and attempting to send an email using this stored procedure code:
CREATE Procedure sp_SMTPMail
@SenderName varchar(100),
@SenderAddress varchar(100),
@RecipientName varchar(100),
@RecipientAddress varchar(100),
@Subject varchar(200),
@Body varchar(8000),
@MailServer varchar(100) = 'localhost'
AS
SET nocount on
SET @SenderName = 'John Smith'
SET @SenderAddress = 'smtprelay.advance.com'
SET @RecipientName = 'John Smith'
SET @RecipientAddress = 'john.smith@advance.com'
SET @Subject = 'Testing SMTP email'
SET @Body = 'From SMTP server'
declare @oMail int --Object reference
declare @resultcode int
EXEC @resultcode = sp_OACreate 'SMTPsvg.Mailer', @oMail OUT
if @resultcode = 0
BEGIN
EXEC @resultcode = sp_OASetProperty @oMail, 'RemoteHost', @mailserver
EXEC @resultcode = sp_OASetProperty @oMail, 'FromName', @SenderName
EXEC @resultcode = sp_OASetProperty @oMail, 'FromAddress', @SenderAddress
EXEC @resultcode = sp_OAMethod @oMail, 'AddRecipient', NULL, @RecipientName, @RecipientAddress
EXEC @resultcode = sp_OASetProperty @oMail, 'Subject', @Subject
EXEC @resultcode = sp_OASetProperty @oMail, 'BodyText', @Body
EXEC @resultcode = sp_OAMethod @oMail, 'SendMail', NULL
EXEC sp_OADestroy @oMail
END
SET nocount off
GO
I am getting the error message:
Server: Msg 201, Level 16, State 4, Procedure sp_SMTPMail, Line 0
Procedure 'sp_SMTPMail' expects parameter '@SenderName', which was not supplied.
This is new to me and I don't quite understand what is going on or what is missing. Any assistance would be greatly appreciated. Thank you.
CREATE Procedure sp_SMTPMail
@SenderName varchar(100),
@SenderAddress varchar(100),
@RecipientName varchar(100),
@RecipientAddress varchar(100),
@Subject varchar(200),
@Body varchar(8000),
@MailServer varchar(100) = 'localhost'
AS
SET nocount on
SET @SenderName = 'John Smith'
SET @SenderAddress = 'smtprelay.advance.com'
SET @RecipientName = 'John Smith'
SET @RecipientAddress = 'john.smith@advance.com'
SET @Subject = 'Testing SMTP email'
SET @Body = 'From SMTP server'
declare @oMail int --Object reference
declare @resultcode int
EXEC @resultcode = sp_OACreate 'SMTPsvg.Mailer', @oMail OUT
if @resultcode = 0
BEGIN
EXEC @resultcode = sp_OASetProperty @oMail, 'RemoteHost', @mailserver
EXEC @resultcode = sp_OASetProperty @oMail, 'FromName', @SenderName
EXEC @resultcode = sp_OASetProperty @oMail, 'FromAddress', @SenderAddress
EXEC @resultcode = sp_OAMethod @oMail, 'AddRecipient', NULL, @RecipientName, @RecipientAddress
EXEC @resultcode = sp_OASetProperty @oMail, 'Subject', @Subject
EXEC @resultcode = sp_OASetProperty @oMail, 'BodyText', @Body
EXEC @resultcode = sp_OAMethod @oMail, 'SendMail', NULL
EXEC sp_OADestroy @oMail
END
SET nocount off
GO
I am getting the error message:
Server: Msg 201, Level 16, State 4, Procedure sp_SMTPMail, Line 0
Procedure 'sp_SMTPMail' expects parameter '@SenderName', which was not supplied.
This is new to me and I don't quite understand what is going on or what is missing. Any assistance would be greatly appreciated. Thank you.