RE: SQL MAIL through SMTP

RE: SQL MAIL through SMTP

 

  

As you stated, Outlook is a MAPI client. It's not needed if he's using
SMTP (or trying). MAPI and SMTP are two separate protocols.

You might want to look over on http://www.sqldev.net for the xp_smtp
package that Gert wrote. It will do what you wwant quite easily and is
THE solution for sending SMTP mail via SQL server.

-----Original Message-----
From: Stig Kagan-Ditlevsen
[mailto:mssqldba-ezmlmshield-x41655682.[Email address protected]
Sent: Thursday, June 29, 2006 1:52 AM
To: LazyDBA Discussion
Subject: SV: SQL MAIL through SMTP

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



---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY Website :
http://www.LazyDBA.com To unsubscribe:
http://www.lazydba.com/unsubscribe.html




---------------------------------------------------------------------------------------------------
NOTICE OF CONFIDENTIALITY
The information contained in this communication and any accompanying document(s) is proprietary and confidential and is intended solely for the above-named individual or entity. If you are not the intended receiver, recipient or entity, you are advised that any distribution, copying, disclosure or communication of this email is strictly prohibited. If you have received this email in error, please contact me at the telephone number listed above or 858.716.1500.
==============================================================================


MS Sql Server LazyDBA home page