IIbIXAPb
  • IIbIXAPb
  • 53% (Neutral)
  • Newbie Topic Starter
6 years ago
Good day. Tested in trial mode your components. Everything's OK. Question: how can I send a letter with a file using MS SQL server? Is there such a possibility? thank
ivan
  • ivan
  • 100% (Exalted)
  • Administration
6 years ago
You can also add an attachment like this


EXEC @hr = sp_OAMethod @oSmtp, 'AddAttachment', @result OUT, 'd:\test.jpg'
If @result <> 0
BEGIN
   EXEC @hr = sp_OAMethod @oSmtp, 'GetLastErrDescription', @description OUT
    PRINT 'failed to add attachment with the following error:'
    PRINT @description
    RETURN
END
IIbIXAPb
  • IIbIXAPb
  • 53% (Neutral)
  • Newbie Topic Starter
6 years ago

You can also add an attachment like this


EXEC @hr = sp_OAMethod @oSmtp, 'AddAttachment', @result OUT, 'd:\test.jpg'
If @result <> 0
BEGIN
   EXEC @hr = sp_OAMethod @oSmtp, 'GetLastErrDescription', @description OUT
    PRINT 'failed to add attachment with the following error:'
    PRINT @description
    RETURN
END

Originally Posted by: ivan 



Thank. Can I attach multiple files this way?
ivan
  • ivan
  • 100% (Exalted)
  • Administration
6 years ago
Yes, you can do it like this:


EXEC @hr = sp_OAMethod @oSmtp, 'AddAttachment', @result OUT, 'd:\test1.jpg'
If @result <> 0
BEGIN
   EXEC @hr = sp_OAMethod @oSmtp, 'GetLastErrDescription', @description OUT
    PRINT 'failed to add attachment with the following error:'
    PRINT @description
    RETURN
END

EXEC @hr = sp_OAMethod @oSmtp, 'AddAttachment', @result OUT, 'd:\test2.jpg'
If @result <> 0
BEGIN
   EXEC @hr = sp_OAMethod @oSmtp, 'GetLastErrDescription', @description OUT
    PRINT 'failed to add attachment with the following error:'
    PRINT @description
    RETURN
END

EXEC @hr = sp_OAMethod @oSmtp, 'AddAttachment', @result OUT, 'd:\test3.jpg'
If @result <> 0
BEGIN
   EXEC @hr = sp_OAMethod @oSmtp, 'GetLastErrDescription', @description OUT
    PRINT 'failed to add attachment with the following error:'
    PRINT @description
    RETURN
END

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.