Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Mail

Mail

Scheduled Pinned Locked Moved Database
questionhtmlsharepointcom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sardinka
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • S sardinka

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/\_denali\_newmail\_object\_cdonts\_library\_.asp?frame=true that should help Will

      S 1 Reply Last reply
      0
      • L Lost User

        http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/\_denali\_newmail\_object\_cdonts\_library\_.asp?frame=true that should help Will

        S Offline
        S Offline
        sardinka
        wrote on last edited by
        #3

        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'

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups