How to send database attachment field as email attachment

笑着哭i 提交于 2020-07-23 17:26:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!