By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,060 Members | 1,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,060 IT Pros & Developers. It's quick & easy.

How to export Email addresses from Query into Outlook?

P: 1
I am currently in the process of making/maintaining a database for a school club. I started the database mostly from scratch and i have a pretty good familiarity with Access (been using it for almost a year), but i hit a wall in terms of something i want to do, and i have a feeling i either need to make an expression, VBA, or macro model to do what i need. I need some direction as to which is the easiest to do, and exactly how i should go about doing it.
I want to be able to create a button on the main page of my database that will open an outlook email message and put all of the email addresses from a column in one of my queries into said outlook mail's "to" form. I do not want it to automatically send the email or attach anything to the email, I just need it to simply fill out the "to" form so that it will act as an active email list.
Any advice would be appreciated, but i have to be honest that i have little experience in VBA. I am not entirely computer illiterate and will probably be able to understand/alter existing code with a little advice. I will provide a little information about my database as i am sure it might be useful for explanation:

Version of Access: Access2003
Name of master table: Membership Master Table
Name of Query based off master table: Current Members
Name of column that email addresses appear in: E-mail
Program to open the emails in: Outlook2007

I appreciate all of the help/advice.
Thank You,
Sep 10 '08 #1
Share this Question
Share on Google+
1 Reply

P: 167
Try this in OnClick event of your button:
Expand|Select|Wrap|Line Numbers
  1. Public rst As Recordset
  2. Public qdf As QueryDef
  3. Dim cID as Variant
  4. Dim MyString As String
  6. cID = Me.cID           'Me.cID is presumed to be ID of your current member
  8. Set qdf = CurrentDb.CreateQueryDef("", "SELECT E-Mail FROM [Current Members] WHERE CurrID= " & cID & ";")
  9. Set rst = qdf.OpenRecordset
  10. If rst.BOF Then
  11.     Exit Sub
  12. Else
  13. rst.MoveFirst
  14. MyString = ""
  15. Do Until rst.EOF
  16.     MyString = MyString & rst![E-Mail] & ";"
  17.     rst.MoveNext
  18. Loop
  21.     DoCmd.SendObject , , , Mystring
Only the CreateQueryDef part could be a little problem, so you need to be carefull there.
Put SQL with the right WHERE part and you have it.
This is one example from my database:
Expand|Select|Wrap|Line Numbers
  1. Set qdf = CurrentDb.CreateQueryDef("", "SELECT * FROM qAiring WHERE abID = " & MovID & "AND aRunNo = " & Run & ";")
Sep 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.