Problems using SendObject

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nwaynik
    New Member
    • Jul 2007
    • 2

    Problems using SendObject

    I'm trying to do something very similar. I get a different error when the email trys to send. The error I get is: "Unknown message recipient(s); the message was not sent." When I substitute 2 or more email addresses in double qoutes for the strEmail variable the code works. I used the "txtEmail" text box to make sure the value of the variable was correct before it passed to the SendObject command. (email1@test.co m; email2@test.com )

    Could someone please take a look at this and tell me what you think? Thanks in advance!

    My Code:

    Code:
        Dim stDocName As String
        stDocName = "rptTest"
        
        Dim rst As DAO.Recordset
        Dim strEmail As String
        
        
        Set rst = CurrentDb.OpenRecordset("SELECT emailAdd As EmailAddress FROM Emails")
        
        Do Until rst.EOF
            strEmail = strEmail & rst!EmailAddress & "; "
            rst.MoveNext
        Loop
        rst.Close
        Set rst = Nothing
        
        txtEmail.Value = strEmail
        
        DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", strEmail, "", "", "Here is the Test email Report", "", False, ""
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Originally posted by nwaynik
    I'm trying to do something very similar. I get a different error when the email trys to send. The error I get is: "Unknown message recipient(s); the message was not sent." When I substitute 2 or more email addresses in double qoutes for the strEmail variable the code works. I used the "txtEmail" text box to make sure the value of the variable was correct before it passed to the SendObject command. (email1@test.co m; email2@test.com )

    Could someone please take a look at this and tell me what you think? Thanks in advance!

    My Code:

    Code:
        Dim stDocName As String
        stDocName = "rptTest"
        
        Dim rst As DAO.Recordset
        Dim strEmail As String
        
        
        Set rst = CurrentDb.OpenRecordset("SELECT emailAdd As EmailAddress FROM Emails")
        
        Do Until rst.EOF
            strEmail = strEmail & rst!EmailAddress & "; "
            rst.MoveNext
        Loop
        rst.Close
        Set rst = Nothing
        
        txtEmail.Value = strEmail
        
        DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", strEmail, "", "", "Here is the Test email Report", "", False, ""
    Dear nwaynik,

    It's best to post a new discussion for your question, thus all experts will be able to participate.

    For your code I would create an escape when there's no row found...

    Nic;o)

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      As Nico says, you need to create a new thread for your question rather than post it in somebody else's thread.
      I have effected that for you by splitting your question from the original thread.

      MODERATOR.

      Comment

      • damonreid
        Recognized Expert New Member
        • Jul 2007
        • 114

        #4
        [code=vb]DoCmd.SendObjec t acReport, stDocName, "RichTextFormat (*.rtf)", strEmail, "", "", "Here is the Test email Report", "", False, ""[/code]

        Try

        [code=vb]DoCmd.SendObjec t acReport, stDocName, "RichTextFormat (*.rtf)", strEmail, "", "", "Here is the Test email Report", "", True[/code]

        Without the final ,"" as it references a template file and you are not pointing at one.
        Last edited by damonreid; Jul 17 '07, 08:52 AM. Reason: Mistake on by behalf

        Comment

        • nwaynik
          New Member
          • Jul 2007
          • 2

          #5
          Sorry about adding it to another's thread and thank you NeoPa for splitting it. I changed two things and everything now works. The first was removing the space after the semicolon. The second thing was to remove a few things from the SendObject command. Below is the code that I changed.

          Thanks for everyone's help!

          Code:
          strEmail = strEmail & rst!EmailAddress & ";"
          Code:
              DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", strEmail, "", "", "Here is the Test email Report", "", False

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            No problem.
            I'm glad you got your problem solved :)

            Comment

            Working...