Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / April 2008

Tip: Looking for answers? Try searching our database.

How to email differnet people in a query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MacrossHunter77 - 19 Apr 2008 04:44 GMT
Hi again I almost finished with a project but I need some help on how to
email diferent people with a table data here is my example

Log (This is the name of the Table)
the fields are
Tracking      Date          Status      Name            e-mail
256482     02/08/08    Complete    John Mano     ManoJ@uy.com
268662     02/08/08    Complete    Nisa Clarbo    ClarboN@yui.com
285425     03/16/08    Complete    Mario Colla     CollaM@rfg.edu
255482     03/17/08    Complete    Mario Colla     CollaM@rfg.edu
255225     03/20/08    InProgress  Ed Martin       Martined@ref.gov
256852     03/22/08    InProgress  Malo Cokn      Cojkm@ref.com

Ok then I create a query Named "Comple Projects Status" frhis is only for
complete projects

256482     02/08/08    Complete    John Mano     ManoJ@uy.com
268662     02/08/08    Complete    Nisa Clarbo    ClarboN@yui.com
285425     03/16/08    Complete    Mario Colla     CollaM@rfg.edu
255482     03/17/08    Complete    Mario Colla     CollaM@rfg.edu

then I want to use a form that is link to this query and use a command button
name e-mail so I can email only this people that have the complete project
status this is what I get confused I need a code that when I Click the email
button automatically put the name of each person to the To: which the
respective information I really don't care if many windows will open I just
want that each person can recieved their complete status data for example
like this

To:ManoJ@uy.com

Message:
256482     John Mano  02/08/08    Complete  

OR LIKE THIS

To:CollaM@rfg.edu

Message:
285425     Mario Colla   03/16/08    Complete    
255482     Mario Colla   03/17/08    Complete

if anyone have a clue about this please let me know I would really appreciate
if you can help me on this thanks
Rick Brandt - 19 Apr 2008 13:44 GMT
> Hi again I almost finished with a project but I need some help on how
> to email diferent people with a table data here is my example

Hopefully you didn't actually just post REAL Email addresses of REAL people
into a public newsgroup.  If so you should apologize to them immediately
about all of the SPAM they will be receiving.

You actually do not need your form bound to this query (unless for other
reasons) in order to assemble and send the Email.

What you do is create a Recordset using a query or SQL statement that
retrieves the Email addresses you want.  Then you loop through that
Recordset appending each address into a string variable separated by
semi-colons.  After completing the loop you use the variable as the TO
argument for SendObject or whatever other code you are using to create the
Email.

UNTESTED EXAMPLE:

Dim db as Database
Dim rs as Recordset
Dim ToVar as String
Set db = CurrentDb
Set rs = db.OpenRecordset("[Comple Projects Status]", dbOpenSnapshot)

Do Until rs.EOF
   ToVar = ToVar & rs![e-mail] &";"
   rs.MoveNext
Loop

(code to send Email)
(code to clean up)

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

MacrossHunter77 - 20 Apr 2008 22:27 GMT
Thank you for your response but really I just made up this emails and names
just to give you guys a idea on how I want this to work, still I exagerated a
little but Like I said these are not real name from real people or emails
still I am going to try you example that might work still I'll let you know
how that goes

>> Hi again I almost finished with a project but I need some help on how
>> to email diferent people with a table data here is my example
[quoted text clipped - 28 lines]
>(code to send Email)
>(code to clean up)
MacrossHunter77 - 21 Apr 2008 17:15 GMT
Hi Rick well I still don't know what code to use for the email code and the
code clean up still I don't have any clue on how to this can you give me a
more info about this thanks

>> Hi again I almost finished with a project but I need some help on how
>> to email diferent people with a table data here is my example
[quoted text clipped - 28 lines]
>(code to send Email)
>(code to clean up)
Rick Brandt - 22 Apr 2008 00:37 GMT
> Hi Rick well I still don't know what code to use for the email code
> and the code clean up still I don't have any clue on how to this can
> you give me a more info about this thanks

Access has a built in function calles SendObject() that will send an Email
using your default MAPI client (Outlook or Outlook Express for example).

Dim db as Database
Dim rs as Recordset
Dim ToVar as String
Set db = CurrentDb
Set rs = db.OpenRecordset("[Comple Projects Status]", dbOpenSnapshot)

Do Until rs.EOF
   ToVar = ToVar & rs![e-mail] &";"
   rs.MoveNext
Loop

DoCmd.SendObject acSendNoObject,,,ToVar,,,"Subject", "Message",True
rs.Close
Set rs = Nothing
Set db = Nothing

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

MacrossHunter77 - 22 Apr 2008 15:49 GMT
Hello Rick well I tried your way and it works but there is a problem i just
noticed that it will take all the email addresses in the field but the
duplicates email will send it again and again for for example if my name is
derick  and I have 5 records the code will email me 5 times for each record
also I noticed that eah individual received the same report, and I really
don't need that I need a code that can email each individual their own
records at the same time I don't want to repeat the emails again and again do
you another code to filter this name please let me know thanks

>> Hi Rick well I still don't know what code to use for the email code
>> and the code clean up still I don't have any clue on how to this can
[quoted text clipped - 18 lines]
>Set rs = Nothing
>Set db = Nothing
Rick Brandt - 22 Apr 2008 19:22 GMT
> Hello Rick well I tried your way and it works but there is a problem
> i just noticed that it will take all the email addresses in the field
[quoted text clipped - 5 lines]
> to repeat the emails again and again do you another code to filter
> this name please let me know thanks

Modify your query to return only the email addresses and then use a DISTINCT
clause.  That will eliminate any duplicates.  For individual Emails you just
move SendObject inside of the loop and drop the variable...

Dim db as Database
Dim rs as Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("[Comple Projects Status]", dbOpenSnapshot)

Do Until rs.EOF
  DoCmd.SendObject acSendNoObject,,,rs![e-mail],,,"Subject", "Message",True
  rs.MoveNext
Loop

rs.Close
Set rs = Nothing
Set db = Nothing

The final True is what makes the message appear in an Outlook window so you
can send it manually.  If don't need that then just change it to False.  As
it is shown you will need to manually press send on each message.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

MacrossHunter77 - 21 Apr 2008 19:01 GMT
Nope it doesn't work rick can you give more clues on how to do this

>> Hi again I almost finished with a project but I need some help on how
>> to email diferent people with a table data here is my example
[quoted text clipped - 28 lines]
>(code to send Email)
>(code to clean up)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.