Sending emails with attachments from Access 
Author Message
 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.



Mon, 19 Jan 2004 17:53:12 GMT  
 Sending emails with attachments from Access
What error?


Quote:
> 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.



Tue, 27 Jan 2004 06:59:51 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VBA MS access sending a email with an attachment

2. Sending Email with Default Email Software WITH Attachment

3. use VBA send a snapshot type report out as an attachment of an email

4. Auotmate email file attachment (upload) and send - help?

5. macro that opens an excel attachment and then sends it to an email address

6. Macro to send email and attachment to current contact

7. Send an Email with Attachment at a Certain Time

8. Removal of attachments on email items in Sent items folder

9. VB6.0 How to send an email attachment from VB Applic

10. Send a email with attachment

11. Send an email with multiple attachments??

12. How to send email attachment?

 

 
Powered by phpBB® Forum Software