473,387 Members | 1,318 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.

sendobject to multiple recipient...help

Hi, i'm sorry for my bad english but ..i'm italian..
I have a big problem that I don't succeed in resolving on the command
sendobjet.
I have a query that as resulted a list of addresses e-mail it
furnishes me
with send object I would like to automatically send a mail to all you
address him present in the query.. as I can do??
I use outlook express... and the object and the text of the mail I
have to compile me..
I would like that is automatically visualized in the recipients TO:
address him some query...

could you write some example of code??

i'm a newbie..

thx very much
alexia
Nov 12 '05 #1
2 7028
You open a recordset based on your query and then iterate through it.

e.g. Query (qryContactEMails) is as follows

SELECT e_mail From Contacts

Where e_mail contains the e-mail address

In DAO you would do something like
Dim loDb As DAO.Database
Dim loRst As DAO.Recordset

Set loDb = CurrentDb
Set loRst = loDb.OpenRecordset("qryContactEMails")

With loRst
Do Until .EOF
DoCmd.SendObject acSendNoObject, _
To:=.Fields("e_mail") & "", _
Subject:="test", _
MessageText:="Hello", _
EditMessage:=False
.MoveNext
Loop
End With
loRst.Close
Set loRst = Nothing
Set loDb = Nothing

In ADO it would be something like
Dim loDb As ADODB.Connection
Dim loRst As ADODB.Recordset

Set loDb = Application.CurrentProject.AccessConnection
Set loRst = loDb.Execute("SELECT * FROM qryContactEMails")

With loRst
Do Until .EOF
DoCmd.SendObject acSendNoObject, _
To:=.Fields("e_mail") & "", _
Subject:="test", _
MessageText:="Hello", _
EditMessage:=False
.MoveNext
Loop
End With
loRst.Close
Set loRst = Nothing
Set loDb = Nothing
Terry

"alessia" <al*******@yahoo.it> wrote in message
news:k8********************************@4ax.com...
Hi, i'm sorry for my bad english but ..i'm italian..
I have a big problem that I don't succeed in resolving on the command
sendobjet.
I have a query that as resulted a list of addresses e-mail it
furnishes me
with send object I would like to automatically send a mail to all you
address him present in the query.. as I can do??
I use outlook express... and the object and the text of the mail I
have to compile me..
I would like that is automatically visualized in the recipients TO:
address him some query...

could you write some example of code??

i'm a newbie..

thx very much
alexia

Nov 12 '05 #2

G'day

I did not write this code it was written by a friend of mine, we have
been working together on the database.

It is a sailing club membership annual invoice. Each member can have 2
email addresses which is the bit in the middle.

It works by printing a report based on a query to html. We did not
spend much time with the report but one thing to remember is that html
does not like lines - if you want a line in your report make it an
underline in a text box.

have fun!
Gus

Sub EmailInvoiceRoutine()

'-----------------------------------------------------------------------
-----------

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim vEmail1 As String
Dim vEmail2 As String
Dim vCode As String
Dim vMailMess As String
Dim vDocName As String
Dim vCheck As String

On Error GoTo Err_EmailInvoiceRoutine

Set db = CurrentDb
Set rst = db.OpenRecordset("tblmemberunits")
Set rst2 = db.OpenRecordset("tblInvoiceDataSourceHTML")
vDocName = "rptInvoiceFirstHTML" ' name of the report to print out
or emial

DoCmd.SetWarnings False
DoCmd.Echo False

rst.MoveFirst
rst2.MoveFirst

'-----------------------------------------------------------------------
-----------

vCheck = MsgBox("This will email invoices to all members who have an
email address on the database" & Chr$(13) & _
"If you do not want to send these immediately please ensure you are
NOT connected to the Interent at this time." & Chr$(13) & Chr$(13) & _
"For those members without Email Addresses, a printout of their
Invoice will be printed to your printer" & Chr$(13) & Chr$(13) & _
"Do you wish to continue ?", vbYesNo, "NSC Invoice Send Routine")

If vCheck = vbNo Then Exit Sub
'-----------------------------------------------------------------------
-----------

' Get Email Message else use default
vMailMess = InputBox("What Subject do you want to appear on your
Email?" & Chr$(13) & _
"Default will be NSC Invoice", "Mail Message", "NSC
Invoice")
'MsgBox vMailMess
'-----------------------------------------------------------------------
-----------

Do Until rst.EOF

' Assign vcode to variable
vCode = rst!code
'MsgBox vCode

' Update temp table for HTML query for code
rst2.Edit
rst2!code = vCode
rst2.Update
'MsgBox rst2!code

' Check Email Address. If null then do not send out.
If IsNull(rst!Email) Then vEmail1 = "None" Else vEmail1 =
rst!Email
If IsNull(rst!Email2) Then vEmail2 = "None" Else vEmail2 =
rst!Email2
'MsgBox vEmail1 & vEmail2

If vEmail1 <> "None" And vEmail2 <> "None" Then
'MsgBox "Two email address"
DoCmd.SendObject acSendReport, "rptInvoiceFirstHTML",
acFormatHTML, _
vEmail1 & ";" & vEmail2, , , vMailMess, , False
ElseIf vEmail2 = "None" And vEmail1 <> "None" Then
'MsgBox "Primary email address only"
DoCmd.SendObject acSendReport, "rptInvoiceFirstHTML",
acFormatHTML, _
vEmail1, , , vMailMess, , False
ElseIf vEmail1 = "None" And vEmail2 <> "None" Then
'MsgBox "Secondary email address only"
DoCmd.SendObject acSendReport, "rptInvoiceFirstHTML",
acFormatHTML, _
vEmail2, , , vMailMess, , False
Else
'MsgBox "No email address"
DoCmd.OpenReport "rptInvoiceFirstHTML", acPreview
End If

rst.MoveNext

Loop

DoCmd.SetWarnings True
DoCmd.Echo True

MsgBox "All Invoices have been processed!"
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

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

Similar topics

7
by: Jay Bienvenu | last post by:
I am trying to execute a DoCmd.SendObject command to produce an email message from Access 2000. The command produces the email message, but the To:, CC: and BCC: fields are blank. The subject field...
0
by: alessia | last post by:
hi I have found this code in this post...
5
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...
0
by: cronept | last post by:
Hi, there, I have a form with 2 email buttons both with docmd.sendobject code. The 1st one send a report which is working properly. The 2nd one send a query in xls format which is always get an...
1
by: Salad | last post by:
I am using Netscape 7.2 as the e-mail client. I can stuff the To, CC, and BCC fields with valid recipients in my application. When I execute the command SendObject I have the option to Edit or...
0
by: sean | last post by:
Dear All, I have written codes to use SendObject to send Fax and email from Access... Yes all were fine. The Outlook could track all that has been sent and track delivery notices if the item has...
8
by: Andy Kasotia | last post by:
Warning message in Outlook 2003 while using SendObject. When i try to use sendobject to send an email, a warning massage pops up, saying that "Outlook is trying to send an email.......if this is...
2
by: Nita | last post by:
Hi, I have no background in scripting (barr HTML) and need some help with hashing out a VB script for a database I'm working on. What my goal is, is to have a single record of a form which is...
1
by: NeoDeGenero | last post by:
I have a little VBA/Access - Reports problem and I’m not sure on how to approach it: I am trying to send a Report generated by MS Access via email through the command SendObject. ...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.