I'm looking for a VBA solution that will allow me to email an attachment (not a report).
As a simple example, I have a table setup as follows:
The 'Quote' field has an 'Attachment' data type. That's what I'm trying to email.
I'm already using the following code to email a report. I'd like to find a way to include attach the attachment (Quote field from the table) to the email also.
Any thoughts or links that you can point me to that might assist? As a point of clarity, I have a form with an attachments textbox on it that
references the record ID, which should allow me to identify the file to attach to the email (hopefully).
Thanks in advance!
Dan
As a simple example, I have a table setup as follows:
The 'Quote' field has an 'Attachment' data type. That's what I'm trying to email.
I'm already using the following code to email a report. I'd like to find a way to include attach the attachment (Quote field from the table) to the email also.
Code:
Function Email()
Dim db As Database
Dim rs As DAO.Recordset
Dim strTO As String
'Dont't forget to reference the Outlook Object Library
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
Set db = CurrentDb
'DoCmd.SetWarnings 0
'Only select records with an email address
Set rs = db.OpenRecordset("SELECT Email FROM Email WHERE Trim(Email & '')<>''")
Do Until rs.EOF
If strTO = "" Then
strTO = rs!Email
Else
strTO = strTO & "; " & rs!Email
End If
rs.MoveNext
Loop
With objEmail
.BCC = strTO
.Subject = "**New RFQ**"
.HTMLBody = "Message"
.Attachments.Add ("\\****\****\****\RFQ.pdf")
'.Attachments.Add ("\\****\****\****\Specs.zip")
.Display
End With
Beep
MsgBox "Email has been sent to recipients.", vbOKOnly, "Done."
'DoCmd.SetWarnings -1
End Function
Any thoughts or links that you can point me to that might assist? As a point of clarity, I have a form with an attachments textbox on it that
references the record ID, which should allow me to identify the file to attach to the email (hopefully).
Thanks in advance!
Dan