问题
I have an Access 2007 database of customers and I am trying to send them a welcome email with their counter signed agreement as an attachment. I am storing their agreement as an attachment field on the customer table. The files will be .docx
MyMail.Attachments.Add Me.Agreement
receives an error: Run-time error '438': Object doesn't support this property or method
I've read a ton of articles that are similar to my issue, but I can't seem to find anything that works.
'Open Outlook
Set MyOutlook = New Outlook.Application
'Creates the e-mail
Set MyMail = MyOutlook.CreateItem(olMailItem)
'Populates the fields
MyMail.To = Me.[ContactEmail]
MyMail.CC = Me.[repEmail]
MyMail.Subject = "Welcome to the evaluation program"
MyMail.Display
MyMail.HTMLBody = Me.[ContactName] & ":" & vbCr & vbCr & [strMessageBody] & vbCr & MyMail.HTMLBody
MyMail.Attachments.Add Me.Agreement
'Display it first
MyMail.Display
End Sub
回答1:
The Attachments.Add method requires a filename in the form "C:\Myfile.txt". You could either save your files as filenames in the database and keep the actual files in another folder or you could save out the files from the attachment field using the SaveToFile method.
来源:https://stackoverflow.com/questions/32323837/how-to-send-database-attachment-field-as-email-attachment