Author |
|
karen32 Newbie
Joined: 30 October 2006
Online Status: Offline Posts: 8
|
Posted: 05 February 2008 at 9:17am | IP Logged
|
|
|
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 |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 06 February 2008 at 4:22am | IP Logged
|
|
|
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 |
|
|