Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-11-14 : 07:41:31
|
| Madhavi writes "I have seen the article 'Sending SMTP Mail using a Stored Procedure' in this site. I modified the code to use Jmail instead of ASP Mail. Below is the code snippet. But it is returning error while adding recipient. So I am unable to send a mail using this. Please help me on this.Thanks & Regards,MadhaviCreate 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 declare @oMail int --Object reference declare @resultcode int EXEC @resultcode = sp_OACreate 'JMail.SMTPMail', @oMail OUT if @resultcode = 0 BEGIN EXEC @resultcode = sp_OASetProperty @oMail, 'ServerAddress', @mailserver EXEC @resultcode = sp_OASetProperty @oMail, 'ServerPort',25 EXEC @resultcode = sp_OASetProperty @oMail, 'Sender', @SenderAddress EXEC @resultcode = sp_OAMethod @oMail, 'AddRecipient', @RecipientAddress print @resultcode EXEC @resultcode = sp_OASetProperty @oMail, 'Subject', @Subject EXEC @resultcode = sp_OASetProperty @oMail, 'Body', @Body EXEC @resultcode = sp_OAMethod @oMail, 'SendMail', NULL EXEC sp_OADestroy @oMail END SET nocount offGO" |
|
|
|
|
|
|
|