Search The ForumSearch   RegisterRegister  LoginLogin

MailBee SMTP

 AfterLogic Forum : MailBee SMTP
Subject Topic: Attachment from DB Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
karen32
Newbie
Newbie


Joined: 30 October 2006
Online Status: Offline
Posts: 8
Posted: 05 February 2008 at 9:17am | IP Logged Quote karen32

Hi,

I am currently using mailbee objects v5.4. Is there a way to add an attachment directly from a db (SQL) w/o having to write the file to the hd from the db, attach it, and then delete it w/o upgrading mailbee?

Thanks,
Karen
Back to Top View karen32's Profile Search for other posts by karen32
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 06 February 2008 at 4:22am | IP Logged Quote Andrew

You can use Message.AddStringAttachment method to add an attachment from a DB without saving temporary files.

Below is an ASP sample for this task:

Code:
Dim sql, objRS, objMsg, objConn

   Set objConn = Server.CreateObject("ADODB.Connection")

   'Set the provider property to the OLE DB Provider for ODBC.
   objConn.Provider = "MSDASQL"

   ' Open a connection using an ODBC DSN.
   objConn.ConnectionString = "driver={SQL Server};" & _
      "server=YourServer;uid=Y ourLogin;pwd=YourPassword;database=DbName"
   objConn.Open


  Set objRS = Server.CreateObject("ADODB.Recordset")

  ' Getting raw body from a blob field
  sql = "SELECT att_data FROM attachments WHERE id = 5"
  objRS.Open sql, objConn, 3, 3

  If Not objRS.EOF Then

   ' Creating empty object
   Set objMsg = Server.CreateObject("MailBee.Message")

   ' Adding the attachment data without saving to disk
   objMsg.AddStringAttachment objRS("att_data").Value, False, "attach.dat"

   ' Displaying message source
   Response.Write objMsg.RawBody
  End If

  ' Closing the recordset
  objRS.Close


Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 

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