all groups > sql server programming > november 2004 >
You're in the

sql server programming

group:

Email using SMTP in SP



Email using SMTP in SP Sri
11/4/2004 10:12:03 PM
sql server programming: I have written the following T-SQL code in a stored procedure to send email
using SMTP. The e-mail is going but the attachment is not going. If I try the
same in VB, the attachment is also going.

SET @strAttach = 'd:\test.txt'

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, 'BCC',@BCC
EXEC @hr = sp_OASetProperty @MailID, 'CC', @CC
EXEC @hr = sp_OASetProperty @MailID, 'Subject', @Subject
EXEC @hr = sp_OASetProperty @MailID, 'To', @To
EXEC @hr = sp_OAMethod @MailID, 'AttachFile', @strAttach
EXEC @hr = sp_OAMethod @MailID, 'Send', NULL
EXEC @hr = sp_OADestroy @MailID

Please help me in this.

Re: Email using SMTP in SP Sri
11/5/2004 2:47:03 AM
Hi Dejan,
Can we do some thing with "CDONTS.dll" using below mentioned code instead of
xp_smtp_sendmail.

Thanks in advance

[quoted text, click to view]
Re: Email using SMTP in SP Dejan Sarka
11/5/2004 8:25:27 AM
You might want to check the xp_smtp_sendmai from
http://sqldev.net/xp/xpsmtp.htm.

--
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com

[quoted text, click to view]

Re: Email using SMTP in SP Aaron [SQL Server MVP]
11/5/2004 9:49:42 AM
[quoted text, click to view]

You can, but I strongly recommend against it. Why do you think invoking COM
objects is better than a stored procedure? Please read
http://www.aspfaq.com/2403

AddThis Social Bookmark Button