From: "Pasha Ahmed Ali" <ahmed_ali_pashahotmail.com>
Subject: Adding Attachments ?
Date: Thu, 26 Jun 2003 23:21:34 -0700
Newsgroups: microsoft.public.sqlserver.ce

I want to know how to add attchments when we send mail
using mssql server writing a store procedure using cdonts
or codsys, I have written the code like this what's wrong
with it, it's not attaching the files as attachments.

CREATE PROCEDURE [dbo].
[sp_send_cdontsmail_cdonts_attachment]
From varchar(100),
To varchar(100),
Subject varchar(100),
Body varchar(4000),
Attachment varchar(100)
AS
Declare MailID int
Declare hr int
EXEC hr = sp_OACreate 'CDONTS.NewMail', MailID OUT
EXEC hr = sp_OASetProperty MailID, 'From',From
EXEC hr = sp_OASetProperty MailID, 'Body', Body
EXEC hr = sp_OASetProperty MailID, 'Subject', Subject
EXEC hr = sp_OASetProperty MailID, 'To', To
EXEC hr = sp_OASetProperty MailID, 'To', To
EXEC hr = sp_OAMethod MailID, 'AddAttachment',
Attachment
EXEC hr = sp_OAMethod MailID, 'Send', NULL
EXEC hr = sp_OADestroy MailID

please help me out.

bye