Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 43
  1. #16
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Good, so it actually attempted to send the email.
    Can you put a break on the Docmd.SendObject and inspect the sEmails variable in the immediate window. What email client are you using? If Outlook I believe you need to go into File\Options\Mail\Send Messages and make sure the setting "Commas can be used to separate multiple..." is checked. Or change the code I've sent you and replace the comma with a semi-colon which is the default Outlook separator.

    Cheers,


    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  2. #17
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53
    It's giving a run-time error again

    Option Compare Database
    Option Explicit




    Private Sub Command0_Click()
    Dim sEmails As String
    Dim qdf As QueryDef, prm As Parameter, rst As DAO.Recordset
    Set qdf = CurrentDb.QueryDefs("Q_All_Emails_no_dups")
    For Each prm In qdf.Parameters
    prm.Value = Eval(prm.Name)
    Next prm


    Set rst = qdf.OpenRecordset


    Set rst = CurrentDb.OpenRecordset("Q_All_Emails_no_dups")
    sEmails = ""
    Do Until rst.EOF
    sEmails = sEmails & rst("Email") & ","
    rst.movenext
    Loop




    sEmails = Left(sEmails, Len(sEmails) - 1) 'trim the last comma




    DoCmd.SendObject acSendNoObject, , , sEmails, , , , , , False
    End Sub

  3. #18
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    What's the error and which line raises it?
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #19
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53
    Got a run-time error 3265 Item not found in this collection

    Set qdf = CurrentDb.QueryDefs("qryMyQuery")

    I changed the "qryMyQuery" to "Q_All_Emails_no_dups" and got the Run-Time Error 2295 again

  5. #20
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Have you looked at the sEmails variable in the immediate window? Add debug.print sEmails after the loop (just before the Docmd.SendObject), put a break on the Docmd.SendObject line and open the immediate window with CTRL+G. Do you see the email addresses there? Have you tried to replace the comma with a semi-colon?
    Code:
    Do Until rst.EOF
    sEmails = sEmails & rst("Email") & ";"
    rst.movenext
    Loop
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #21
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53
    I put a break on the line. the runtime error highlights this syntax

    DoCmd.SendObject acSendNoObject, , , sEmails, , , , , , False

  7. #22
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    What is the sEmails variable? Hover the mouse over it or do what I suggested in the previous post (debug.print sEmails).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #23
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Are you using Outlook? Have you checked the option to allow commas as email list separator?
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #24
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53
    Sorry this is getting so confusing.

    Here's what I have. Nothing show in the immediate window.

    Option Compare Database
    Option Explicit




    Private Sub Command0_Click()
    Dim sEmails As String
    Dim qdf As QueryDef, prm As Parameter, rst As DAO.Recordset
    Set qdf = CurrentDb.QueryDefs("Q_All_Emails_no_dups")
    For Each prm In qdf.Parameters
    prm.Value = Eval(prm.Name)
    Next prm


    Set rst = qdf.OpenRecordset


    Set rst = CurrentDb.OpenRecordset("Q_All_Emails_no_dups")
    sEmails = ""
    Do Until rst.EOF
    sEmails = sEmails & rst("Email") & ";"
    rst.movenext
    Loop




    sEmails = Left(sEmails, Len(sEmails) - 1) 'trim the last comma


    Debug.Print sEmails
    DoCmd.SendObject acSendNoObject, , , , , sEmails, , , , False
    End Sub

  10. #25
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53
    I am using Outlook

  11. #26
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    You need to put a break on the Docmd.SendObject line, click the button and when the code stops on that line (it will turn yellow) press CTRL+G to open the Immediate window. In there you should see the value of the sEmails variable printed by the previous line. Are you saying you are doing all this and you see nothing?
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  12. #27
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53
    Yes, I put a break on the line and it turn yellow but there is nothing in the Immediate window.

  13. #28
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Then you need to check the name of the query and the email field and make sure it returns your expected records. Here is what I get in the small sample I am attaching to this post:
    Click image for larger version. 

Name:	Capture.jpg 
Views:	7 
Size:	116.2 KB 
ID:	44137
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  14. #29
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53
    All the names looks right and the query does give the results I want. I'll work on it more tomorrow.

  15. #30
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Sure thing, good luck!
    Post back if you get stuck.

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 08-08-2019, 11:03 AM
  2. Add attachments from database to email
    By Vol71 in forum Access
    Replies: 4
    Last Post: 07-21-2015, 11:09 AM
  3. Using query to group attachments for email
    By Monterey_Manzer in forum Access
    Replies: 7
    Last Post: 05-31-2013, 01:37 PM
  4. If and Multiple Email Attachments
    By beckysright in forum Programming
    Replies: 5
    Last Post: 12-13-2012, 03:25 PM
  5. Send email with attachments
    By rbiggs in forum Programming
    Replies: 12
    Last Post: 07-23-2011, 12:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums