Send contents of attachment field? (1 Viewer)

mistyinca1970

Member
Local time
Today, 09:02
Joined
Mar 17, 2021
Messages
117
Is this possible? I have .pdf files in the attachment fields of records. Is it possible to send those in an email? I can't seem to find a way to do this using SendObject.

Thank you,
 

Isaac

Lifelong Learner
Local time
Today, 09:02
Joined
Mar 14, 2017
Messages
8,738
you'll probably have to write some code to download the attachment(s), then send them using outlook, cdo, etc
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:02
Joined
May 21, 2018
Messages
8,463
I have the code to do this, but not here. Could send this evening.
You have to save it first to disk, then send. Then remove from disk.
 

mistyinca1970

Member
Local time
Today, 09:02
Joined
Mar 17, 2021
Messages
117
I have the code to do this, but not here. Could send this evening.
You have to save it first to disk, then send. Then remove from disk.
It has to be a disk? Can't be an internet file location?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:02
Joined
May 21, 2018
Messages
8,463
Sorry, that I do not know. I have never saved a file to an internet location via vba.
 

Isaac

Lifelong Learner
Local time
Today, 09:02
Joined
Mar 14, 2017
Messages
8,738
here is some code i use, it loops through multiple attachments and saves them using the primary record's ID value plus some datetime stuff

Code:
Dim rsOuter As DAO.Recordset, rsInner As DAO.Recordset2
Dim fldAttachments As DAO.Field2, db As DAO.Database, strFolderPath as String
Set db = CurrentDb
strFolderPath="c:\documents\etc"
Set rsOuter = db.OpenRecordset("select [ID],[attachments] from [tablename]")

'loop thru all SP records:
Do Until rsOuter.EOF = True
    Set fldAttachments = rsOuter.Fields("Attachments")
    Set rsInner = fldAttachments.Value
    Do Until rsInner.EOF = True
        strFilePath = strFolderPath & "\" & rsOuter.Fields("ID").Value & "_" & Format(Now, "mmddyyhhmmss") & ".xlsb"
        rsInner("FileData").SaveToFile strFilePath
        rsInner.MoveNext
    Loop
    rsOuter.MoveNext
Loop
 

Users who are viewing this thread

Top Bottom