Hi,

So I have a procedure that creates an email and I would like to attach a document that is held in a table (tablename: tblImages, fieldname: Image) as an attachment type.

Currently the only way I can do this is to save the attachment to the hard drive, then attach it to the email and then delete it from the hard drive as per the below code:

Set db = CurrentDb
    Set rsParent = db.OpenRecordset("tblImages")
    rsParent.MoveFirst
    Set rsChild = rsParent("Image").Value
       
    Set fld = rsChild("FileData")
    strPath = CurrentProject.Path & "\" & rsChild("Filename")
    On Error Resume Next
    Kill strPath
    On Error GoTo 0
    
    fld.SaveToFile strPath
        Set myOlApp = CreateObject("Outlook.Application")
    Set myEmail = myOlApp.CreateItem(olMailItem)
    
    
    With myEmail
        .SentOnBehalfOfName = sOnBehalf
        .To = sRecipient
        .Subject = sSubject
        .Attachments.Add strPath, olByValue, 0
        .HTMLBody = sBody
        .Display
    End With
    Kill strPath
Does anyone know if there is a way to attach the file from the table without saving to the hard drive first?

I am using MS Access 2013.