Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2004
    Posts
    178

    Unanswered: email code not working

    i want to send a report to list of people the code i am using it comes up with type missmatch


    Private Sub Command44_Click()
    On Error GoTo Err_Command44_Click
    Dim MyDB As Database
    Dim MyRS As Recordset
    Dim TheAddress As String
    Dim stDocName As String
    Set MyDB = CurrentDb
    Set MyRS = MyDB.OpenRecordset("tblCustmers")
    MyRS.MoveFirst
    Do Until MyRS.EOF
    TheAddress = MyRS![EmailAddress]

    stDocName = "repFridayFlyerA4"
    DoCmd.SendObject acReport, stDocName, acFormatHTML, TheAddress, , , "movie Program " & Text2, , , True
    Loop
    Exit_Command44_Click:
    Exit Sub

    Err_Command44_Click:
    MsgBox Err.Description
    Resume Exit_Command44_Click

    End Sub

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    This usually results from having ambiguity in the Recordset type when you have both ADO and DAO libraries defined in Refrences. Change your Dimension (Dim Statement) to specifiy ADO Recordset or (in this case) DAO Recordset
    from:
    Dim MyRS As Recordset
    To:
    Dim MyRS As DAO Recordset

    /
    Last edited by savbill; 01-17-05 at 00:31.
    ~

    Bill

  3. #3
    Join Date
    Aug 2004
    Posts
    178
    That worked fine thanks. now how do i get it to send so i dont have to click on the send in the email

  4. #4
    Join Date
    Feb 2004
    Posts
    533
    Take a look at this post Sending an email via Access 2000 for some ideas. The examples in the post define MS Outlook as an object then use outlook vb commands to create/send the emails. This only works with Outlook, not Outlook Express, as Outlook 2000 and later has the VB IDE component built in.

    If you are using Outlook Express then you could try doing something with sendkeys to push the Send Button or Shortcut Key command. You would want to use appActivate, to make sure Outlook Express is active with your message ready to send, then call the send command shortcut. This get rather clunky and error prone, but I've done it before.

    If you have a lot of email to send on a regular basis you may want to use a third party program like Fairlogic WorldCast. You can do database imports to update the email list and send attachments.

    /
    ~

    Bill

  5. #5
    Join Date
    Aug 2004
    Posts
    178
    this code is now working but the loop wont stop

    Private Sub Command44_Click()
    On Error GoTo Err_Command44_Click
    Dim MyDB As Database
    Dim MyRS As dao.Recordset
    Dim TheAddress As String
    Dim stDocName As String
    Set MyDB = CurrentDb
    Set MyRS = MyDB.OpenRecordset("qryEmailFlyer")
    MyRS.MoveFirst
    Do Until MyRS.EOF
    TheAddress = MyRS![EmailAddress]

    stDocName = "repFridayFlyerA4"
    DoCmd.SendObject acReport, stDocName, acFormatHTML, TheAddress, , , "movie program Starting " & Text2, , False

    Loop
    Exit_Command44_Click:
    Exit Sub

    Err_Command44_Click:
    MsgBox Err.Description
    Resume Exit_Command44_Click

    End Sub

  6. #6
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    he he - put in a MyRs.MoveNext within the loop (after the sendobject, but before the loop statement)

    I laugh, because, however many times I've written recordset thingies, about half the times I do the same...
    Roy-Vidar

  7. #7
    Join Date
    Nov 2004
    Posts
    32
    It just seems so obvious, but I've got to put my hand up t this mistake as well.


  8. #8
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    ctrl+break and the three finger salute are my friends
    Roy-Vidar

  9. #9
    Join Date
    Aug 2004
    Posts
    178
    Thanks very much it works fine now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •