473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.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
5 2935
nico5038
3,080 Expert 2GB
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
32,556 Expert Mod 16PB
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
114 Expert 100+
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
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
32,556 Expert Mod 16PB
No problem.
I'm glad you got your problem solved :)
Jul 17 '07 #6

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

Similar topics

0
by: Bret Shortall | last post by:
Using the SENDOBJECT action command in a Macro works fine if you hard code in their email address. SENDOBJECT TO bret@emailaddress.com SUBJECT This is the Subject line...
1
by: Alfred | last post by:
Hi I am using access 2002 1.0 I want to email a word or html file using the docmd.sendobject The document must be send as a attachment. 2.0 Second I would like to tell the Docmd.Sendobject to...
2
by: Lumpierbritches | last post by:
Hello, and thank you in advance for any and all assistance. I'm having a problem. This code worked years ago, what am I doing wrong? Private Sub SendeMail_Click() DoCmd.SendObject...
5
by: Mark | last post by:
Hi All, Is there a way to (whilst using the sendobject command) use a query as the source of email addresses. I ask this because the list is constanly changing and I don't want to keep going into...
1
by: Tom Louchbaum | last post by:
When I preview my Access 2000 Report it looks fine. When I Email the report using DoCmd.SendObject acSendReport, "Report", acFormatRTF, "To Address", , , "Subject", , False the resulting...
1
by: John Taylor | last post by:
I have finally got "SendObject" to work but now have a filter problem. I have a database set up that I generate orders and print them as a single page report. I've set up a filter so that when I...
2
by: Marcus | last post by:
Is there a way to have Access 2002 open a particular email client, when using DoCmd.SendObject? So far, Access simply opens the default email client that is set under Control Panel/Internet...
0
by: Klaus Herzberg | last post by:
Hallo, with a access-application i send reports via email/SendObject. After installing office 2007 beta the Sendobject doesn't work. Also after deinstalling office 2007. The error: 2046 "the...
2
by: John Taylor | last post by:
I have created a command button on a form that prints a filtered report and e-mails the report to three people when "clicked". The three email addresses are selected on the form by three combo...
2
by: Owen Mac | last post by:
Hello everyone, Is it possible to use an email address from a table and/or query with the Sendobject Method. An email address from my form works fine...what I would like is the 'To:' section be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.