A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Email distribution list idea.



 
 
Thread Tools Display Modes
  #1  
Old February 1st, 2005, 10:09 PM
Jonathan Brown
external usenet poster
 
Posts: n/a
Default Email distribution list idea.

Okay, I think this one might be little tough. Though I'm learning very
quickly that there's nothing too difficult for all you geniuses out there.

Here's what I'd like to do. I've got a Personel table with related contact
information and I've got a Sites table. there's a one to many relationship
between the Personel and Sites tables. Many people can be a one site. What
I'd like to do is have a form with a drop down list box that shows all of the
site names, and a button. When I click this button I want a blank email to
open up that has all of the email addresses of the individuals that are
related to that site in the To: field.

I think the code should probably look something like this but different:

***************Begginning of Code*********************
Dim objOutlook As New Outlook.Application
Dim objMail As MailItem

Set objOutlook = New Outlook.Application
Set objMail = objOutlook.CreateItem(olMailItem)

EmailAddr = Me.Email
CopyEmailAddr = ""
Subj = "Information about the FSR Update database."
Body = ""
PathName = ""

With objMail
.To = EmailAddr
.cc = CopyEmailAddr
.Subject = Subj
.Body = Body
.NoAging = True
.Display
End With
********************End of Code***********************

The EmailAddr variable will have to contain all of the email addresses of
the individuals of a certain site. I probably need a function that finds out
those email addresses that assigns them to a variable that I can call
somehow. Anyway, I have no idea. Any help would be appreciated. Thanks a
ton for all the help I've received in previous posts.
  #2  
Old February 2nd, 2005, 02:22 AM
Sandra Daigle
external usenet poster
 
Posts: n/a
Default

Hi Jonathan,

To build a list of all the email addresses you simply open a recordset that
returns all the email addresses for the given site, loop through it and
build your string. First, build a query that selects the Personel for the
selected Site. This is pretty easy to do - if your combo for sites is named
cboSiteId and the form is named "frmEmailer" then youre query would be
something like this:

Select EmailAddress from tblPersonel where
Siteid=forms!frmEmailer!cboSiteID;

Save this query as "qrySelEmailBySite"

Then the code to use this query to build a string would be something like
this:

dim rst as dao.recordset
dim db as dao.database
dim strEmail as string
set db=currentdb()
set rst=db.openrecordset("qrySelEmailBySite")
with rst
if not .bof and .eof then
do until .eof
strEmail=strEmail & .fields("EmailAddress") & "; "
.movenext
loop
endif
.close
end with

strEmail will contain the list of email addresses.

For more information on this you might want to take a look at the following
article - this one sends a separate email to each address but the article
might give you some ideas anyway:

ACC97: How to Use a Recordset to Send Outlook E-Mail to Multiple Recipients
http://support.microsoft.com/?id=318881


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Jonathan Brown wrote:
Okay, I think this one might be little tough. Though I'm learning very
quickly that there's nothing too difficult for all you geniuses out there.

Here's what I'd like to do. I've got a Personel table with related
contact information and I've got a Sites table. there's a one to many
relationship between the Personel and Sites tables. Many people can be a
one site. What I'd like to do is have a form with a drop down list box
that shows all of the site names, and a button. When I click this button
I want a blank email to open up that has all of the email addresses of
the individuals that are related to that site in the To: field.

I think the code should probably look something like this but different:

***************Begginning of Code*********************
Dim objOutlook As New Outlook.Application
Dim objMail As MailItem

Set objOutlook = New Outlook.Application
Set objMail = objOutlook.CreateItem(olMailItem)

EmailAddr = Me.Email
CopyEmailAddr = ""
Subj = "Information about the FSR Update database."
Body = ""
PathName = ""

With objMail
.To = EmailAddr
.cc = CopyEmailAddr
.Subject = Subj
.Body = Body
.NoAging = True
.Display
End With
********************End of Code***********************

The EmailAddr variable will have to contain all of the email addresses of
the individuals of a certain site. I probably need a function that finds
out those email addresses that assigns them to a variable that I can call
somehow. Anyway, I have no idea. Any help would be appreciated. Thanks
a ton for all the help I've received in previous posts.


  #3  
Old April 27th, 2006, 09:37 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Email distribution list idea.

I started with the code below and made a few modifications. It's posted
under another discussion thread - search for "send email" and it should be in
a thread started by a user named Connie. So far it's working pretty well for
me.

"Sandra Daigle" wrote:

Hi Jonathan,

To build a list of all the email addresses you simply open a recordset that
returns all the email addresses for the given site, loop through it and
build your string. First, build a query that selects the Personel for the
selected Site. This is pretty easy to do - if your combo for sites is named
cboSiteId and the form is named "frmEmailer" then youre query would be
something like this:

Select EmailAddress from tblPersonel where
Siteid=forms!frmEmailer!cboSiteID;

Save this query as "qrySelEmailBySite"

Then the code to use this query to build a string would be something like
this:

dim rst as dao.recordset
dim db as dao.database
dim strEmail as string
set db=currentdb()
set rst=db.openrecordset("qrySelEmailBySite")
with rst
if not .bof and .eof then
do until .eof
strEmail=strEmail & .fields("EmailAddress") & "; "
.movenext
loop
endif
.close
end with

strEmail will contain the list of email addresses.

For more information on this you might want to take a look at the following
article - this one sends a separate email to each address but the article
might give you some ideas anyway:

ACC97: How to Use a Recordset to Send Outlook E-Mail to Multiple Recipients
http://support.microsoft.com/?id=318881


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Jonathan Brown wrote:
Okay, I think this one might be little tough. Though I'm learning very
quickly that there's nothing too difficult for all you geniuses out there.

Here's what I'd like to do. I've got a Personel table with related
contact information and I've got a Sites table. there's a one to many
relationship between the Personel and Sites tables. Many people can be a
one site. What I'd like to do is have a form with a drop down list box
that shows all of the site names, and a button. When I click this button
I want a blank email to open up that has all of the email addresses of
the individuals that are related to that site in the To: field.

I think the code should probably look something like this but different:

***************Begginning of Code*********************
Dim objOutlook As New Outlook.Application
Dim objMail As MailItem

Set objOutlook = New Outlook.Application
Set objMail = objOutlook.CreateItem(olMailItem)

EmailAddr = Me.Email
CopyEmailAddr = ""
Subj = "Information about the FSR Update database."
Body = ""
PathName = ""

With objMail
.To = EmailAddr
.cc = CopyEmailAddr
.Subject = Subj
.Body = Body
.NoAging = True
.Display
End With
********************End of Code***********************

The EmailAddr variable will have to contain all of the email addresses of
the individuals of a certain site. I probably need a function that finds
out those email addresses that assigns them to a variable that I can call
somehow. Anyway, I have no idea. Any help would be appreciated. Thanks
a ton for all the help I've received in previous posts.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I email a distribution list with only the recipients name . anthea myers General Discussion 4 January 26th, 2005 09:21 AM
Distribution list membership display Sue Mosher [MVP-Outlook] General Discussion 0 January 24th, 2005 10:26 PM
Email Distribution List from Access AMH General Discussion 1 December 31st, 2004 12:13 AM
error message when sending email to distribution list terryjar General Discussion 1 September 28th, 2004 08:35 PM
How do I send an email to an already-created distribution list? amf626 Contacts 1 September 21st, 2004 09:10 PM


All times are GMT +1. The time now is 12:24 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.