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: - 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, ""
5 2935
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: - 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)
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.
- DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", strEmail, "", "", "Here is the Test email Report", "", False, ""
Try - 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.
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! - strEmail = strEmail & rst!EmailAddress & ";"
- DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", strEmail, "", "", "Here is the Test email Report", "", False
-
NeoPa 32,556
Expert Mod 16PB
No problem.
I'm glad you got your problem solved :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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$) {
}
...
|
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
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
| |