Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 23rd, 2005, 06:57 PM
krisw538 krisw538 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 24 krisw538 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 16 m 59 sec
Reputation Power: 0
Email Distribution Lists, etc.

In my table, I have email address stored for most of the entries. I could add another field to determine which type of email they would receive.

I set one up as a hyperlink and when I clicked on it, it opened up and email and populated the address for me. I know this is common knowledge but here's the question...

What would be the easiest way to call up all the addresses in a certain category and have all of them populated into a blank email as blind copy, with the subject, from, and body populated as well?

Thanks in advance

Reply With Quote
  #2  
Old August 24th, 2005, 09:18 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
Hi krisw538,

First create a query that is filtered by your requirements (i.e. certain category).

The following code can be put behind a command button on a form for example:

Private Sub cmdEmail_Click()
On Error GoTo Err_Handler
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strTo As String, strCC As String, strBCC As String
Dim strSubject As String, strMessage As String
strTo = "recipient@someaddress.com" 'Address to send to (required)
strCC = "recipient@someaddress.com" 'Address to copy to (optional)
strSubject = "This is your Subject Line"
strMessage = "This is your Message Text"
Set db = CurrentDb
Set rs = db.OpenRecordset("qryName", dbOpenSnapshot)
Do Until rs.EOF
With rs
If Not IsNull(rs!Email) Then 'Make sure that an email address exists
strBCC = strBCC & rs!Email & "; "
End If
.MoveNext
End With
Loop
strBCC = Left(strBCC, Len(strBCC) - 2) 'Addresses to Blind copy to
Set db = Nothing
Set rs = Nothing
DoCmd.SendObject , , , strTo, strCC, strBCC, strSubject, strMessage
Exit_Handler:
Exit Sub
Err_Handler:
If Err.Number = 2501 Then 'In case the email was canceled
Resume Exit_Handler
Else
MsgBox Err.Number & " " & Err.Description
Resume Exit_Handler
End If
End Sub

You would change what is bold above to the exact name of the query you created and use the exact name of the field that holds the email addresses. Be sure you have the references set to the DAO library under Tools/References while in your forms code module. The above code will not validate the email addresses so it would be up to you to make sure that a valid email address was entered correctly into the table.

lwells

Reply With Quote
  #3  
Old August 24th, 2005, 01:53 PM
krisw538 krisw538 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 24 krisw538 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 16 m 59 sec
Reputation Power: 0
Thank you, I'll try it out

Reply With Quote
  #4  
Old September 3rd, 2005, 05:31 PM
krisw538 krisw538 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 24 krisw538 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 16 m 59 sec
Reputation Power: 0
Thank you so much, this worked great!

I only have one question about it. How would I go about making it use no more than 70 email addresses at a time since aol won't allow for mass emailing. At the end of 70 email addresses, have it open another email form with same information but using the next group of 70?

Thanks in advance,
Kris

Quote:
Originally Posted by lwells
Hi krisw538,

First create a query that is filtered by your requirements (i.e. certain category).

The following code can be put behind a command button on a form for example:

Private Sub cmdEmail_Click()
On Error GoTo Err_Handler
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strTo As String, strCC As String, strBCC As String
Dim strSubject As String, strMessage As String
strTo = "recipient@someaddress.com" 'Address to send to (required)
strCC = "recipient@someaddress.com" 'Address to copy to (optional)
strSubject = "This is your Subject Line"
strMessage = "This is your Message Text"
Set db = CurrentDb
Set rs = db.OpenRecordset("qryName", dbOpenSnapshot)
Do Until rs.EOF
With rs
If Not IsNull(rs!Email) Then 'Make sure that an email address exists
strBCC = strBCC & rs!Email & "; "
End If
.MoveNext
End With
Loop
strBCC = Left(strBCC, Len(strBCC) - 2) 'Addresses to Blind copy to
Set db = Nothing
Set rs = Nothing
DoCmd.SendObject , , , strTo, strCC, strBCC, strSubject, strMessage
Exit_Handler:
Exit Sub
Err_Handler:
If Err.Number = 2501 Then 'In case the email was canceled
Resume Exit_Handler
Else
MsgBox Err.Number & " " & Err.Description
Resume Exit_Handler
End If
End Sub

You would change what is bold above to the exact name of the query you created and use the exact name of the field that holds the email addresses. Be sure you have the references set to the DAO library under Tools/References while in your forms code module. The above code will not validate the email addresses so it would be up to you to make sure that a valid email address was entered correctly into the table.

lwells

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Email Distribution Lists, etc.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT