Solved

Email to all contacts in Access Database

Posted on 2014-04-10
12
744 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

There are many add-ons for Google docs, slides and sheets that can be extremely helpful in keeping your files organized and simple to use. Add-ons are installed into your Google docs, slides or sheets through Google's Add-On Store. One of my favorit…
The choice of selecting a perfect productive suite for one’s organization is a critical decision that an IT Manager or a CIO has to make. And when it comes to choosing a cloud-based productivity suite, the choice gets all the more difficult. This is…
This Micro Tutorial demonstrates the importance of annotations in Google Analytics and how they should be used to document changes made to a site, Google updates (Ex: Panda & Penguin), marketing campaigns, and any other events that might have contri…
This Micro Tutorial demonstrates in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

830 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