Solved

Email to all contacts in Access Database

Posted on 2014-04-10
12
676 Views
Last Modified: 2014-11-12
This question might be a little difficult and I have totally no idea how to do, please show me step by step if possible (I never done this before)
   How do I do if I want to send a email to all the people that I have in my database at the same time from a gmail account.  for example, right now I only have two people in the DB, but I will be adding more in the future, I want to go to my gmail account and send an email to everyone and I don't want to send one by one, is anyway to do that?  That I can do from my gmail and select all the email address from my database?  I attach my DB too
AFSCME.mdb
0
Comment
Question by:urjudo
  • 6
  • 4
  • 2
12 Comments
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39992365
you can write vba code in the database to send emails to whoever you want.
0
 

Author Comment

by:urjudo
ID: 39992372
where I can start? do you have any example?
0
 
LVL 7

Assisted Solution

by:COACHMAN99
COACHMAN99 earned 100 total points
ID: 39992398
coding the whole app will take me too much time unfortunately, but the key functions are

you will need to add a reference to the Outlook object library - tools/references in the vba window.

Function SendEmail(RecipEmail As String, Subject As String, BBody As String, cc1 As String) As Boolean
  On Error GoTo err_SendEmail
  Dim olApp As Outlook.Application
  Dim oItem As Outlook.MailItem
  Dim tInterval As Integer, signature As String
  If RecipEmail <> "" Then
    SendEmail = False
    Set olApp = CreateObject("Outlook.Application")
    Set oItem = olApp.CreateItem(olMailItem)
    With oItem
      .To = RecipEmail & IIf(cc1 <> "", "; " & cc1, "")
      .Display   'to get signature for later use
      signature = Nz(DLookup("CurricCoordSignature", "tblPrograms_LOOKUP", "Prog_Num=" & Nz(Forms("frmMain").cboProgram, 0)), 0) '.Body
      .Subject = Subject
      .Body = BBody & vbCr & vbCr & signature
    End With
    If Nz(gAttach1, "") <> "" Then oItem.Attachments.Add (cAttachmentPath & gAttach1)
    oItem.Display

  End If
  SendEmail = True
exit_SendEmail:
  On Error Resume Next
  Set olApp = Nothing
  Set oItem = Nothing
  Exit Function
err_SendEmail:
  MsgBox "Error " & Err.Number & ", " & Err.Description & " Occurred in SendEmail after " & ErrorLine
  Resume exit_SendEmail
End Function
0
 
LVL 26

Accepted Solution

by:
MacroShadow earned 400 total points
ID: 39992809
I prefer CDO. Attached please find a sample.
AFSCME.mdb
0
 

Author Comment

by:urjudo
ID: 39994136
Hi Marcoshadow,  
Thank you so much for the example, but when I made change for the code such as add my real gmail address, password, it seems when I click the send email button, it does not do anything, may be I need to check any of the References?
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39994178
No need for references. Try placing a break point in the beginning of the code and step thru it, that way you can see what's happening.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:urjudo
ID: 39994201
it stops at If rs.BOF <> rs.EOF, the error message is "re.EOF =<object variable or with block variable not set>"
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39994556
1. there is a typo: re.EOF instead of rs.EOF
2. add
rs.movelast
rs.movefirst

Open in new window


before the line that errs out.
0
 

Author Comment

by:urjudo
ID: 40005339
for some reason, it seems the button is still not doing anything  after i added the two lines and fixed the code, do i need to  change anything in the modules? such as the "username" & "password"?
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 40005354
Is there an error, if so, which and where?
0
 

Author Comment

by:urjudo
ID: 40005371
it still stop on the if rs.bof<>rs.eof , the same message that i mentioned before, even i already put my gmail address and password, that's i was wandering if i need to change anything in the module that states "username"and "password" to be the same as i have in the send email button code?
0
 

Author Closing Comment

by:urjudo
ID: 40007778
Thank you!!!!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

One of my favorite tools to use with Google Drive is the offline access. Setting up offline access for Google Drive makes it easier for users to edit and view their docs, sheets and slides without Internet connection. Follow these steps to learn how…
If your app took Google’s lash recently, here are the 5 most likely reasons.
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now