CDOSYS mail | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

CDOSYS mail

Hi,
I am using the following stored procedure to send a mail with attachment. But the mail is sent without the attachment. Can anyone help me?
Regards,
Bharathram G

What stored procedure is that?[<img src=’/community/emoticons/emotion-4.gif’ alt=’:p‘ />]<br /><br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Bharathram2911</i><br /><br />Hi,<br /> I am using the following stored procedure to send a mail with attachment. But the mail is sent without the attachment. Can anyone help me?<br />Regards,<br />Bharathram G<br /><br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br />Karl Grambow<br /><br />www.sqldbcontrol.com
Sorry this is the SP:
CREATE PROCEDURE DBO.sp_Send_Mail_test(
@p_From as nvarchar(50),
@p_To as nvarchar(50),
@p_Subject as nvarchar(255),
@p_Body as varchar(1000),
@p_CC as text = null,
@p_BCC as text = null,
@p_Attachment varchar(500)=null
)
AS
Declare @Message int
Declare @hr int
Declare @source varchar(255)
Declare @description varchar(500) EXEC @hr = sp_OACreate ‘CDO.Message’, @Message OUT EXEC @hr = sp_OASetProperty @Message, ‘From’,@p_From EXEC @hr = sp_OASetProperty @Message, ‘To’, @p_To EXEC @hr = sp_OASetProperty @Message, ‘Subject’, @p_Subject EXEC @hr = sp_OASetProperty @Message, ‘TextBody’, @p_Body EXEC @hr = sp_OAMethod @Message, ‘CDO.Message.Attachment.Update’, Default, @p_Attachment If @p_CC is not null
BEGIN
EXEC @hr = sp_OASetProperty @Message, ‘CC’,@p_CC
END If @p_BCC is not null
BEGIN
EXEC @hr = sp_OASetProperty @Message, ‘BCC’,@p_BCC
END EXEC @hr = sp_OAMethod @Message, ‘Send’, NULL EXEC @hr = sp_OAGetErrorInfo NULL, @source OUT, @description out
EXEC @hr = sp_OADestroy @Message
IF @hr <> 0
BEGIN
SELECT hr=convert(varbinary(4),@hr), [email protected], [email protected]
RETURN
END
]]>