-
I have following sp: How do I need to modify this sp in order to handle attachements? CREATE PROCEDURE CDO_SendMail( @From varchar(255) = 's@yahoo.com', @To varchar(255), @Cc varchar(255) = '', @Bcc varchar(255) = '', @Subject varchar(255), @MessageFormat int = 0, -- default to HTML, 1 = text, 0 = html @Message varchar(8000), @Priority int = 2 -- default to high, 1 = normal, 0 = low ) AS DECLARE @CDO int, @OLEResult int, @Out int --Create CDONTS.NewMail object EXECUTE @OLEResult = sp_OACreate 'CDONTS.NewMail', @CDO OUT IF @OLEResult <> 0 PRINT 'CDONTS.NewMail' --Set CDONTS.NewMail properties execute @OLEResult = sp_OASetProperty @CDO, 'From', @From execute @OLEResult = sp_OASetProperty @CDO, 'To', @To execute @OLEResult = sp_OASetProperty @CDO, 'Cc', @Cc execute @OLEResult = sp_OASetProperty @CDO, 'Bcc', @Bcc execute @OLEResult = sp_OASetProperty @CDO, 'Subject', @Subject execute @OLEResult = sp_OASetProperty @CDO, 'BodyFormat', @MessageFormat execute @OLEResult = sp_OASetProperty @CDO, 'Body', @Message execute @OLEResult = sp_OASetProperty @CDO, 'Importance', @Priority --Call Send method of the object execute @OLEResult = sp_OAMethod @CDO, 'Send', Null IF @OLEResult <> 0 PRINT 'Send' --Destroy CDO EXECUTE @OLEResult = sp_OADestroy @CDO return @OLEResult GO
-
I have following sp: How do I need to modify this sp in order to handle attachements? CREATE PROCEDURE CDO_SendMail( @From varchar(255) = 's@yahoo.com', @To varchar(255), @Cc varchar(255) = '', @Bcc varchar(255) = '', @Subject varchar(255), @MessageFormat int = 0, -- default to HTML, 1 = text, 0 = html @Message varchar(8000), @Priority int = 2 -- default to high, 1 = normal, 0 = low ) AS DECLARE @CDO int, @OLEResult int, @Out int --Create CDONTS.NewMail object EXECUTE @OLEResult = sp_OACreate 'CDONTS.NewMail', @CDO OUT IF @OLEResult <> 0 PRINT 'CDONTS.NewMail' --Set CDONTS.NewMail properties execute @OLEResult = sp_OASetProperty @CDO, 'From', @From execute @OLEResult = sp_OASetProperty @CDO, 'To', @To execute @OLEResult = sp_OASetProperty @CDO, 'Cc', @Cc execute @OLEResult = sp_OASetProperty @CDO, 'Bcc', @Bcc execute @OLEResult = sp_OASetProperty @CDO, 'Subject', @Subject execute @OLEResult = sp_OASetProperty @CDO, 'BodyFormat', @MessageFormat execute @OLEResult = sp_OASetProperty @CDO, 'Body', @Message execute @OLEResult = sp_OASetProperty @CDO, 'Importance', @Priority --Call Send method of the object execute @OLEResult = sp_OAMethod @CDO, 'Send', Null IF @OLEResult <> 0 PRINT 'Send' --Destroy CDO EXECUTE @OLEResult = sp_OADestroy @CDO return @OLEResult GO
-
here is my sp. For some reason it won't attache file. Any idea why? CREATE PROCEDURE CDO_SendMail_test( @From varchar(255) = 's@yahoo.com', @To varchar(255), @Cc varchar(255) = '', @Bcc varchar(255) = '', @Subject varchar(255), @MessageFormat int = 0, -- default to HTML, 1 = text, 0 = html @Message varchar(8000), @Priority int = 2, @AttachFile varchar(8000) -- default to high, 1 = normal, 0 = low ) AS DECLARE @CDO int, @OLEResult int, @Out int --Create CDONTS.NewMail object EXECUTE @OLEResult = sp_OACreate 'CDONTS.NewMail', @CDO OUT IF @OLEResult <> 0 PRINT 'CDONTS.NewMail' --Set CDONTS.NewMail properties execute @OLEResult = sp_OASetProperty @CDO, 'From', @From execute @OLEResult = sp_OASetProperty @CDO, 'To', @To execute @OLEResult = sp_OASetProperty @CDO, 'Cc', @Cc execute @OLEResult = sp_OASetProperty @CDO, 'Bcc', @Bcc execute @OLEResult = sp_OASetProperty @CDO, 'Subject', @Subject execute @OLEResult = sp_OASetProperty @CDO, 'BodyFormat', @MessageFormat execute @OLEResult = sp_OASetProperty @CDO, 'Body', @Message execute @OLEResult = sp_OASetProperty @CDO, 'Importance', @Priority execute @OLEResult = sp_OAMethod @CDO, 'AttachFile', @AttachFile--'' [, ''] [, ] --Call Send method of the object execute @OLEResult = sp_OAMethod @CDO, 'Send', Null IF @OLEResult <> 0 PRINT 'Send' --Destroy CDO EXECUTE @OLEResult = sp_OADestroy @CDO return @OLEResult GO exec CDO_SendMail_test @From = 'yyr@yahoo.com', @To = 'tt@chickering.com', @Cc = '', @Bcc = '', @Subject = 'test', @MessageFormat = 0, @Message = '', @AttachFile ='\\bsar\test.txt'
Database
3
Posts
2
Posters
0
Views
1
Watching