473,386 Members | 1,748 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,386 software developers and data experts.

Access2003 + CDO + TO: (how do I pull TO: list from table)

Hi All ~ First time posting.

I have a module that works ... it contains:

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
.From = "PSS Mass Mail Mailbox"
.Sender = "hu***********@usa.com"
.To = "hu***********@usa.com"
.Subject = "Hugh Message"

How can I get it to pull email addresses from a table or query?
I want it to send "To" this list rather than just one email address.
Both in same database. Table1 & Query1 (field: email)
Your help is appreciated
Hugh
Jan 10 '08 #1
6 1843
"HughMcMenamin" <u39813@uwewrote in message news:7df937d650446@uwe...
Hi All ~ First time posting.

I have a module that works ... it contains:

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
.From = "PSS Mass Mail Mailbox"
.Sender = "hu***********@usa.com"
.To = "hu***********@usa.com"
.Subject = "Hugh Message"

How can I get it to pull email addresses from a table or query?
I want it to send "To" this list rather than just one email address.
Both in same database. Table1 & Query1 (field: email)
Your help is appreciated
Hugh
First make sure you have a reference to 'Microsoft DAO 3.6 Object Library'
(In the VBE, Tools->References), then:

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset(Query1, dbOpenSnapshot)

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
Do Until rs.EOF
.From = "PSS Mass Mail Mailbox"
.Sender = "hu***********@usa.com"
.To = rs!email
.Subject = "Hugh Message"
'...
.MoveNext
Loop
rs.Close
Set rs = Nothing

Just to satisfy my curiosity, what is objCDOConfig?
Jan 10 '08 #2
Stuart ~ Thanks a million for your reply!
I tried to do what you said but it didnt work .....I've played with it, so
now it is at least working and pulling from the query, but just the first
entry. I could not get the LOOP or go to END OF FILE to work for me.
I have no idea where this code came from, a friend gave it to me and asked me
to see if I could get it to work from a query. I'm waiting to hear back from
him to answer your question. Perhaps you can understand from the full code
below. Can you teach me how to make it work, pulling the entire field from
the query? I would be most grateful, sir!
' ************************************************** ******************************
Public Sub testCDO()

Const cdoSendUsingPort = 2
Const cdoBasic = 1
Dim objCDOConfig As Object, objCDOMessage As Object
Dim strSch As String

strSch = "http://schemas.microsoft.com/cdo/configuration/"
Set objCDOConfig = CreateObject("CDO.Configuration")
With objCDOConfig.Fields
.Item(strSch & "sendusing") = cdoSendUsingPort
.Item(strSch & "smtpserver") = "smtp.server.Com"

.Update
End With

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("Query1", dbOpenSnapshot)

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig

.From = "Hugh Mailbox"
.Sender = "hu***********@usa.com"
.To = rs![email]
.Subject = "Hugh Message"

.HTMLBody = "Here is the body of Hughs email"
.send
End With
Set objCDOMessage = Nothing
Set objCDOConfig = Nothing
End Sub
' ************************************************** **************************************
Stuart McCall wrote:
>Hi All ~ First time posting.
[quoted text clipped - 13 lines]
>Your help is appreciated
Hugh

First make sure you have a reference to 'Microsoft DAO 3.6 Object Library'
(In the VBE, Tools->References), then:

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset(Query1, dbOpenSnapshot)

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
Do Until rs.EOF
.From = "PSS Mass Mail Mailbox"
.Sender = "hu***********@usa.com"
.To = rs!email
.Subject = "Hugh Message"
'...
.MoveNext
Loop
rs.Close
Set rs = Nothing

Just to satisfy my curiosity, what is objCDOConfig?
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/200801/1

Jan 11 '08 #3
On Jan 10, 8:20 am, "HughMcMenamin" <u39813@uwewrote:
Hi All ~ First time posting.

I have a module that works ... it contains:

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
.From = "PSS Mass Mail Mailbox"
.Sender = "hughmcmena...@usa.com"
.To = "hughmcmena...@usa.com"
.Subject = "Hugh Message"

How can I get it to pull email addresses from a table or query?
I want it to send "To" this list rather than just one email address.
Both in same database. Table1 & Query1 (field: email)
Your help is appreciated
Hugh
With Access 2000, 2002, or 2003 you could try:

..To = CurrentProject.Connection.Execute("Select EmailAddress FROM
SomeTable").GetString(adClipString, ,";")

Jan 12 '08 #4
Thank you Lyle - got it to work. Have a great weekend.

lyle wrote:
>Hi All ~ First time posting.
[quoted text clipped - 13 lines]
>Your help is appreciated
Hugh

With Access 2000, 2002, or 2003 you could try:

.To = CurrentProject.Connection.Execute("Select EmailAddress FROM
SomeTable").GetString(adClipString, ,";")
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200801/1

Jan 12 '08 #5
.To = CurrentProject.Connection.Execute("Select EmailAddress FROM
SomeTable").GetString(adClipString, ,";")
Very neat, and I would think much faster than my offering. Do you know what
the character limit is for the .To field?
Jan 13 '08 #6
On Jan 12, 7:23 pm, "Stuart McCall" <smcc...@myunrealbox.comwrote:
.To = CurrentProject.Connection.Execute("Select EmailAddress FROM
SomeTable").GetString(adClipString, ,";")

Very neat, and I would think much faster than my offering. Do you know what
the character limit is for the .To field?
I don't know. I suspect that we could "send" the .TO property any VBA
string which is ... hmmm ... limited to 2 ^ 16 - 1 = 65535? characters
(just guessing as I think length of strings is stored in the 2 bytes
immediately preceeding the actual characters in memory.)
But what would our smtp server accept? Could we expect all smtp
servers to be the same? I wouldn't but maybe they are. I expect it
might require a "try it with whatever size you like until it fails"
investigation. That size may be too big, assuming there is no other
cause for the failure.
Jan 13 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Belinda | last post by:
Hello All I need to read a SQL Server table into a Web Page and within the Web Page to permit my users to make changes to the records, delete or add new records and then save the entire contents...
9
by: 2D Rick | last post by:
With the help from members in the VB forum I've pieced together code that works in VB6 to create radial text similar to "text on a path" seen in graphics programs.(on a circle only) I use an...
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
4
by: Jan | last post by:
Have an SQL create/import script. Running this on SQL would make it create a table with some values. Can Access2003 somehow use such and SQL script? I went into SQL query view to try it out, but...
3
by: ouldm8 | last post by:
Hi everybody, How can i get SQL Source of my tables in ACCESS 2003?? Please help. Thanks
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
7
by: karen987 | last post by:
The code below is for an asp page that pulls out a list of authors in a given category, from a news weblog. In this case, the category id (CID) is "37" . So the page should list all authors from...
2
by: logo3 | last post by:
hello, I'm trying to fill the table named "ALBARANES" which is based on a query. The query use table "structureOK". There are 3 additional values should be updated. AS Expr2 AS Expr3 AS...
3
by: Ramchandar | last post by:
Hi, I am creating reports using VBA code. I have the same query in a querydef residing both in Access97 and Access2003. The result of this querydef is then moved to a table in Access97 and...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.