Results 1 to 6 of 6
  1. #1
    Kennertoy is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    29

    Question Automate Emails from Query - SendObject

    I have a Access 2000 DB where we would like to send emails to recipients from our data base with an accompanying letter. We had hoped that we could create and run a query to filter recipients, then using that data send a word document to all recipients listed in the query (in groups (50) emails at a time to the server. Our server blocks any more as spam). We have up to groups of 250 to send. Also, the mailserver will not accept the bulk email if there is a mistake in any of the email address destined for a local recipient (on the same mail server). In other words I have to trap the error and correct the incorrect email address before the job will complete thru the mail server.
    It is a bit beyond my expertise to program. And maybe it's a bit of pie in the sky.
    Would someone from the forum would have had this challenge?
    Your help would be appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    It could be done. This link shows how to send a single email http://forums.aspfree.com/microsoft-...ro-447084.html

    Sending multiple emails would require using coded SQL recordset, read records from the recordset and either send one at a time or compile a string of addresses for the To property. With either will require looping code structure.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Kennertoy is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    29

    Email Blaster

    Thanks Jane, I found dmoe code that works but only to one email address. Now I'll have to find a way to capture all my email addresses out of the qry and patch them into this code. Any ideas?

  4. #4
    Kennertoy is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    29

    Email Blaster

    Sorry about that 'JUNE7'

  5. #5
    Kennertoy is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    29

    Email Blaster

    A bit new with this posting. June7 I forgot to show the code:
    The recipient 'Add("Nancy Davolio")' is where I have to make a chnage send the email to numerous people.
    ------------------------------------------
    Sub sbSendMessage(Optional AttachmentPath)
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment

    On Error GoTo ErrorMsgs

    ' Create the Outlook session.
    Set objOutlook = CreateObject("Outlook.Application")
    ' Create the message.
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    With objOutlookMsg
    ' Add the To recipient(s) to the message. Substitute
    ' your names here.
    Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
    objOutlookRecip.Type = olTo
    ' Add the CC recipient(s) to the message.
    Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
    objOutlookRecip.Type = olCC
    ' Set the Subject, Body, and Importance of the message.
    .Subject = "This is an Automation test with Microsoft Outlook"
    .Body = "Last test." & vbCrLf & vbCrLf
    .Importance = olImportanceHigh 'High importance

    ' Add attachments to the message.
    If Not IsMissing(AttachmentPath) Then
    Set objOutlookAttach = .Attachments.Add(AttachmentPath)
    End If
    ' Resolve each Recipient's name.
    For Each objOutlookRecip In .Recipients
    If Not objOutlookRecip.Resolve Then
    objOutlookMsg.Display
    End If
    Next
    .Send
    End With
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
    Set objOutlookRecip = Nothing
    Set objOutlookAttach = Nothing

    Exit Sub

    ErrorMsgs:
    If Err.Number = "287" Then
    MsgBox "You clicked No to the Outlook security warning. " & _
    "Rerun the procedure and click Yes to access e-mail " & _
    "addresses to send your message. For more information, " & _
    "see the document at http://www.microsoft.com/office" & _
    "/previous/outlook/downloads/security.asp. "
    Else
    MsgBox Err.Number & " " & Err.Description

    -------------------------------------

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Google: VBA send multiple emails

    Here is one on how to send multiple individual emails http://www.access-programmers.co.uk/...d.php?t=180507

    In that loop you can have code to verify the email address and correct if needed or not send and move on to the next record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 03-15-2011, 07:35 AM
  2. Automatic Emails
    By smit2215 in forum Queries
    Replies: 1
    Last Post: 03-10-2011, 01:23 PM
  3. Access emails
    By Gargen in forum Access
    Replies: 5
    Last Post: 08-04-2010, 01:10 PM
  4. Automatic emails.
    By motherboard in forum Queries
    Replies: 3
    Last Post: 05-04-2010, 11:03 AM
  5. How to automate a access query ... Help me
    By kusamharsha in forum Programming
    Replies: 0
    Last Post: 02-25-2009, 09:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums