ASP to SP

P

Paulo

How to put these configuration ASP fields on the SP some lines below? I need
to send email via SP
------------------------------------------------------
Set iMsg = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' Set the CDOSYS configuration fields to use port 25 on the SMTP server.
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.uol.com.br"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")
= 10
.Update
End With
-----------------------SP MS SQL SERVER
2000---------------------------------------------------------
EXEC @RESULTADO = SP_OACREATE 'CDO.Message', @OMAIL OUT
EXEC @RESULTADO1 = SP_OACREATE 'CDO.Configuration', @OMAIL1 OUT
IF (@RESULTADO = 0) And (@RESULTADO1 = 0) -- no error
BEGIN
EXEC @RESULTADO = SP_OASETPROPERTY @OMAIL, 'FROM' , @FROM_ADDRESS --
ENDEREÇO DE EMAIL FROM
EXEC @RESULTADO = SP_OASETPROPERTY @OMAIL, 'TO' , @TO_ADDRESS -- ENDEREÇO
DE EMAIL TO
-- VERIFICANDO SE O ENDEREÇO CC NÃO ESTÁ VAZIO
IF @CC_ADDRESS <> ''
BEGIN
EXEC @RESULTADO = SP_OASETPROPERTY @OMAIL, 'CC', @CC_ADDRESS -- ENDEREÇO
DE EMAIL CC
END
-- VERIFICANDO SE O ENDEREÇO BCC NÃO ESTÁ VAZIO
IF @BCC_ADDRESS <> ''
BEGIN
EXEC @RESULTADO = SP_OASETPROPERTY @OMAIL, 'BCC', @BCC_ADDRESS --
ENDEREÇO DE EMAIL BCC
END
EXEC @RESULTADO = SP_OASETPROPERTY @OMAIL, 'SUBJECT', @ASSUNTO_EMAIL --
ASSUNTO
EXEC @RESULTADO = SP_OASETPROPERTY @OMAIL, 'TextBody', @MENSAGEM_EMAIL --
CORPO DO EMAIL
-- TIPO DE EMAIL (TEXTO/HTML)
--EXEC @RESULTADO = SP_OASETPROPERTY @OMAIL, 'BODYFORMAT', @TIPO_EMAIL
--EXEC @RESULTADO = SP_OASETPROPERTY @OMAIL, 'MAILFORMAT', @TIPO_EMAIL
-- ENVIANDO O EMAIL
 
B

Bob Barrows [MVP]

Aarggh! You are making things very difficult using the sp_oa stuff. I
use xp_smtp to send mail from sql server. It is much simpler and more
robust than instantiating external com objects.
See http://www.sqldev.net/xp/xpsmtp.htm

Note that SQL 2005 is not listed in the supported platforms, but we're
running the SQL2000 version on our 2005 servers with no problems. Not
that this should concern you since you are using 2000

If you prefer not to use this free, easy-to-use tool, see
http://classicasp.aspfaq.com/email/how-do-i-send-e-mail-from-sql-server.html
 
P

Paulo

Bob, must the IIS SMTP server enabled to send emails using the xp_smtp.dll?
IIS and MS SQL are on the same machine!

Any configuration else?

Thanks man!
 
B

Bob Barrows [MVP]

It's all in the help document. You can point it at any accessible smtp
server.
 
P

Paulo

Bob, my SMTP server needs to be authenticated before send emails... how can
I do that via programming? any properties on this component?

Thank you!
 
B

Bob Barrows [MVP]

The parameters are listed here:
http://www.sqldev.net/xp/xpsmtp.htm#Parameters
I don't see any way to pass authentication credentials so it appears you
have a choice of using SQL Server's MAPI-based xp_SendMail or checking
out the KB article cited in the aspfaq article for help with using sp_oa
to work with CDO
 
B

Bob Barrows [MVP]

Oh, and if nobody jumps in here to give you some more help with this,
you might try the m.p.sqlserver.programming group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top