Hi,
Do you have Outlook or Exchange installed on the SqlServer - it's my
experience that that is required to use Sql Mail (Mapi Client)
/Stig Kagan-Ditlevsen
-----Oprindelig meddelelse-----
Fra: Vinoth R
[mailto:mssqldba-ezmlmshield-x5547818.[Email address protected]
Sendt: 29. juni 2006 10:49
Til: LazyDBA Discussion
Emne: SQL MAIL through SMTP
Hi guys,
I have a problem when I send mails through SQL SERVER using SMTP. It
doesn't generate any errors but the mail is not going, I don't know why
Please help me in the same, am I missing something important
The following is the code
create Procedure dbo.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 'SMTPsvg.Mailer', @oMail OUT
---------- and I replace this 'SMTPsvg.Mailer' with the domain name
found in IIS
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
------------------- EXECUTING USING
exec sp_SMTPMail @SenderName='abc', @SenderAddress='[Email address
protected]
@RecipientName = 'uwv', @RecipientAddress = '[Email address protected]
@Subject='SQL TEST MAIL', @body='Hello, this is a test email from SQL
Server. Please Ignore'
Thanks in advance
Vini
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
Website : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
MS Sql Server LazyDBA home page