Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2006
    Posts
    4

    Unanswered: DoCmd.SendObject

    Need a little help. I'd like to send the same message to a list of email addresses that are contained in a separate table. I've tried:

    DoCmd.SendObject acReport, "Upcoming Week OT Report", "RichTextFormat(*.rtf)", Email.[Email], "", "", "Upcoming Week OT Report", "", False, ""

    where Email.email is the distribution I'd like to email to. Any words of wisdom? Code?

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Emailing

    Maybe this attachment might help.
    Attached Files Attached Files
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Sep 2006
    Posts
    4
    Wow, this looks great. It'll take me a bit to chew through the fine points, but many Thanks!!! Will let you know how it comes out.

  4. #4
    Join Date
    Sep 2006
    Posts
    4

    Talking Solution works

    I took out the variables for message and subject since I'm fine right now with standard text strings, and kept everything else. It's working like a champ! Many Thanks. My Outlook now warns me, though for every individual email sent. I'll have to either see how I can avoid getting this error or look to create a string based on the emailaddresses table. Thanks Again!

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I'm not sure if you can turn this off. We were not able to when sending attachments (because of our virus checker) so we went to a small email program called Blat. The vba code to send the email is fairly simple (I have a copy somewhere). Blat I believe is free and also pretty easy to install (and small in size). We used it on our server for sending emails with attachments.
    Last edited by pkstormy; 09-28-06 at 21:59.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  6. #6
    Join Date
    Sep 2006
    Posts
    4
    Paul, I took your base and instead of emailing in the loop sequence, I created a string of emails based on the EmailAddresses. Then, email'd to the entire string. See below. I've learned so much doing this! Thank you!

    Private Sub cmdEmail_Click()
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Dim strSQL As String
    Dim eSub, eText As Variant
    Dim emaillist As String
    strSQL = "Select * from EmailTable"
    eSub = Me!msgSubject
    eText = Me!msgMessage
    rs.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
    rs.MoveFirst
    Do While Not rs.EOF
    emaillist = rs!EmailAddress & ";" & emaillist
    rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing
    DoCmd.SendObject acSendReport, "MyEmailReport", acFormatRTF, emaillist, , , eSub, eText, False
    End Sub

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by dszmauz
    Paul, I took your base and instead of emailing in the loop sequence, I created a string of emails based on the EmailAddresses. Then, email'd to the entire string. See below. I've learned so much doing this! Thank you!

    Private Sub cmdEmail_Click()
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Dim strSQL As String
    Dim eSub, eText As Variant
    Dim emaillist As String
    strSQL = "Select * from EmailTable"
    eSub = Me!msgSubject
    eText = Me!msgMessage
    rs.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
    rs.MoveFirst
    Do While Not rs.EOF
    emaillist = rs!EmailAddress & ";" & emaillist
    rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing
    DoCmd.SendObject acSendReport, "MyEmailReport", acFormatRTF, emaillist, , , eSub, eText, False
    End Sub
    You do know the difference between the 2 ways don't you? In original, only the recipient sees the email... Your way, each recipient sees ALL THE OTHER recipients of the same email ... It may or may not make a difference to you ... In some instances it will: Say sending an email to your suppliers ... You would not want to send 1 email out to all your suppliers ... They would know about each other as related to you from you ... OOOPS!
    Back to Access ... ADO is not the way to go for speed ...

Posting Permissions

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