
Sending emails with attachments from Access
Folks, can anybody help me!
I have a problem sending emails with attachments from Access - method Add of
object Attachments raises an error. As I get it, it should work, could
somebody tell what's wrong. Here is the example:
Option Explicit
Dim WithEvents MI As MailItem
Private Sub btnSend_Click()
On Error GoTo ErrHandler
Dim o As Object, RS As Recordset, At As Attachments
Set o = CreateObject("Outlook.Application")
Set MI = o.CreateItem(olMailItem)
MI.Subject = Nz(Me.Subject, "")
MI.Body = Nz(Me.Body, "")
MI.To = Me.ToEmail
Set At = MI.Attachments
Set RS = Me.EmailAttachments.Form.RecordsetClone
Do Until RS.EOF
At.Add RS!AttachmentPath, olByValue 'Here an error occurs
RS.MoveNext
Loop
MI.Display
Exit Sub
...
When the code adds an attachment an error occurs:
"-2009461581; Operation is not supported for this type of object."
What could be the problem with it?
Thanks a lot.