By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,462 Members | 2,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,462 IT Pros & Developers. It's quick & easy.

Problems using SendObject

P: 2
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.com; email2@test.com)

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

My Code:

Expand|Select|Wrap|Line Numbers
  1.     Dim stDocName As String
  2.     stDocName = "rptTest"
  3.  
  4.     Dim rst As DAO.Recordset
  5.     Dim strEmail As String
  6.  
  7.  
  8.     Set rst = CurrentDb.OpenRecordset("SELECT emailAdd As EmailAddress FROM Emails")
  9.  
  10.     Do Until rst.EOF
  11.         strEmail = strEmail & rst!EmailAddress & "; "
  12.         rst.MoveNext
  13.     Loop
  14.     rst.Close
  15.     Set rst = Nothing
  16.  
  17.     txtEmail.Value = strEmail
  18.  
  19.     DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", strEmail, "", "", "Here is the Test email Report", "", False, ""
Jul 16 '07 #1
Share this Question
Share on Google+
5 Replies


nico5038
Expert 2.5K+
P: 3,072
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.com; email2@test.com)

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

My Code:

Expand|Select|Wrap|Line Numbers
  1.     Dim stDocName As String
  2.     stDocName = "rptTest"
  3.  
  4.     Dim rst As DAO.Recordset
  5.     Dim strEmail As String
  6.  
  7.  
  8.     Set rst = CurrentDb.OpenRecordset("SELECT emailAdd As EmailAddress FROM Emails")
  9.  
  10.     Do Until rst.EOF
  11.         strEmail = strEmail & rst!EmailAddress & "; "
  12.         rst.MoveNext
  13.     Loop
  14.     rst.Close
  15.     Set rst = Nothing
  16.  
  17.     txtEmail.Value = strEmail
  18.  
  19.     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)
Jul 16 '07 #2

NeoPa
Expert Mod 15k+
P: 31,186
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.
Jul 16 '07 #3

damonreid
Expert 100+
P: 114
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", strEmail, "", "", "Here is the Test email Report", "", False, ""
Try

Expand|Select|Wrap|Line Numbers
  1. DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", strEmail, "", "", "Here is the Test email Report", "", True
Without the final ,"" as it references a template file and you are not pointing at one.
Jul 17 '07 #4

P: 2
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!

Expand|Select|Wrap|Line Numbers
  1. strEmail = strEmail & rst!EmailAddress & ";"
Expand|Select|Wrap|Line Numbers
  1.     DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", strEmail, "", "", "Here is the Test email Report", "", False
  2.  
Jul 17 '07 #5

NeoPa
Expert Mod 15k+
P: 31,186
No problem.
I'm glad you got your problem solved :)
Jul 17 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.