Solved

Email to all contacts in Access Database

Posted on 2014-04-10
12
809 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 27

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 27

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
 

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 27

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 27

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

 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

627 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