Fensbo,
I use outlook, and it looks like that is what you will be using too. I have a documents table (named EmailDocuments) that has a link to where the documents are located on the server, as well as a yes/no check box to determine if that document is to be attached or not. Then I run a loop to attach all documents that are checked (yes or true) to attach.
On my form, I have a subform that has all of the documents where they can be searched through and checked if the user wants them sent. Each time the form is opened it goes through and unchecks any documents that are checked so that the documents that were sent the last time are not attached again.
I am fairly new to Access programming, but here is the code I use. The code is ran by clicking a button that calls the following function. eg. Call MailParameters
'Code Start
Function MailParameters()
Dim rstT As DAO.Recordset
Dim strSQL As String
Dim strAttatch As String
Dim outApp As Outlook.Application
Dim outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)
'these three lines set the recordset for the files I want attached.
strSQL = "SELECT DocumentsEmail.*, DocumentsEmail.Attach"
strSQL = strSQL & " FROM DocumentsEmail WHERE Attach= Yes"
Set rstT = CurrentDb.OpenRecordset(strSQL)
'starting the outlook message.
With outMsg
'.Importance = olImportanceHigh
.To = Contact@address.com
'.CC = "CC EMAIL ADDRESS GOES HERE"
'.BCC = "BCC EMAIL ADDRESS GOES HERE"'
'.Subject = "Proposal"
.Body = "Dear whomever”
'here is the loop that attaches the files.
If rstT.RecordCount > 0 Then
With rstT
.MoveFirst
Do While Not .EOF
strAttatch = !DocumentLink
outMsg.Attachments.Add (strAttatch)
.MoveNext
Loop
.Close
End With
End If
Set rstT = Nothing
' If you want the screen to be seen then add the following line
.Display
'.Send 'This is if you want to automatically send the message
End With
Set outApp = Nothing
Set outMsg = Nothing
End Function
'End Code
I am going to work today or tomorrow on getting it to be able to add multiple recipients as well, if this works for you and you would like the code addition when I finish it, let me know.
Good luck,
Eric