Search The ForumSearch   RegisterRegister  LoginLogin

MailBee SMTP

 AfterLogic Forum : MailBee SMTP
Subject Topic: smtp from extended stored proc Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Morten
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 02 February 2005 at 3:49pm | IP Logged Quote Morten

has anyone played around with wrapping mailbee smtp functionality in an extended stored procedure?

Morten
Back to Top View Morten's Profile Search for other posts by Morten
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 03 February 2005 at 9:16am | IP Logged Quote Alex

Here is a simple MSSQL script which sends mail using MailBee.SMTP (it does not use SMTP authentication, logging, etc.), just shows the idea:

Code:

DECLARE @object int
DECLARE @hr int
DECLARE @property varchar(255)
DECLARE @return varchar(255)
DECLARE @src varchar(255), @desc varchar(255)

-- Create an object.
EXEC @hr = sp_OACreate 'MailBee.SMTP', @object OUT
IF @hr <> 0
BEGIN
   EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
   SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
    RETURN
END

-- Set a property.
EXEC @hr = sp_OASetProperty @object, 'LicenseKey', 'type license key here'
IF @hr <> 0
BEGIN
   EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
   SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
    RETURN
END

-- Set a property.
EXEC @hr = sp_OASetProperty @object, 'ServerName', 'localhost'
IF @hr <> 0
BEGIN
   EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
   SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
    RETURN
END

-- Set a property.
EXEC @hr = sp_OASetProperty @object, 'FromAddr', 'from@localhost'
IF @hr <> 0
BEGIN
   EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
   SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
    RETURN
END

-- Set a property.
EXEC @hr = sp_OASetProperty @object, 'ToAddr', 'to@localhost'
IF @hr <> 0
BEGIN
   EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
   SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
    RETURN
END

-- Set a property.
EXEC @hr = sp_OASetProperty @object, 'Subject', 'MailBee From MS SQL'
IF @hr <> 0
BEGIN
   EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
   SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
    RETURN
END

-- Call a method that returns a value.
EXEC @hr = sp_OAMethod @object, 'Send', @return OUT
IF @hr <> 0
BEGIN
   EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
   SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
    RETURN
END
PRINT @return

-- Destroy the object.
EXEC @hr = sp_OADestroy @object
IF @hr <> 0
BEGIN
   EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
   SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
    RETURN
END


Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide