Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 13th, 2003, 12:11 PM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access 2000 and Outlook

I have a table that has information regarding my clients. (Name, address, tel. number, zip code, e-mail address,)
Now I want to use the e-mail address of each individual to send him or her his or her own records.
Take the information that corresponds to that client and by using his/her e-mail address send it to them.
Is there any sample program that shows how to read the information form each field in Access table and put it in an e-mail message corresponding to that individual?
I know I need to integrate access with Outlook and MS Word (Composing my messages). Information needs to be changed in message body according to that particular individual record. Example: Name, Address, ... will be different for all 500 individuals.
I need to send almost 500 e-mails but I don't want for them to see each other’s information.

 
Old August 13th, 2003, 03:18 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Depending on what you want to send them, or how. You can use something similar to this. I use this to send reports select from a previous form, and pass those perameters to this function to create and send the e-mails. Let me know if you need more help on this.....


Function SendEMail(ByVal strfile As String, strSubject As String, strMessage As String, strProp As String, intProc As Integer)
On Error GoTo SendErr
'************************************************* ********
'* Purpose: Sends E-Mail via Outlook *
'* Author: John Anthony *
'* Date Written: 5/29/03 *
'* Last Modified:6/5/03 *
'* Added in code to handle missing CC names*
'* 8/1/03 *
'* Functionality for E-mail IMCU tables *
'************************************************* ********

    Dim olApp As Outlook.Application
    Dim olMail As Outlook.MailItem
    Dim olRecipient As Outlook.Recipient
    Dim olCCRecipient As Outlook.Recipient
    Dim blnKnownRecipient As Boolean
    Dim db As Database
    Dim rec As Recordset, rec2 As Recordset
    Dim strSQL As String, strSQL2 As String
    Dim Recipient As String, CCRecipient As String
    Dim intAtt As Integer
    Dim strF2 As String

    Set db = CurrentDb()

    If intProc = 1 Then '8/1/03
        Set rec = db.OpenRecordset("tblDistributionListIMCU", dbOpenDynaset)
        Set rec2 = db.OpenRecordset("tblDistributionListIMCUCC", dbOpenDynaset)
    Else
        strSQL = "SELECT * FROM tblDistributionList" & _
                " WHERE (((tblDistributionList.PropertyCode)='" & strProp & "'));"

        strSQL2 = "SELECT * FROM tblDistributionListCC" & _
                " WHERE (((tblDistributionListCC.PropertyCode)='" & strProp & "'));"

        Set rec = db.OpenRecordset(strSQL, dbOpenDynaset)
        Set rec2 = db.OpenRecordset(strSQL2, dbOpenDynaset)
    End If



    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)

    With olMail
        rec.MoveFirst
            Do While rec.EOF = False
                Recipient = rec.Fields("Distribution")
                Set olRecipient = .Recipients.Add(Recipient)
                olRecipient.Type = olTo
            rec.MoveNext
        Loop

        If rec2.RecordCount > 0 Then
            rec2.MoveFirst
                Do While rec2.EOF = False
                    CCRecipient = rec2.Fields("Distribution")
                    Set olCCRecipient = .Recipients.Add(CCRecipient)
                    olCCRecipient.Type = olCC
                rec2.MoveNext
            Loop
        End If

        blnKnownRecipient = olRecipient.Resolve
        .Subject = strSubject

        If intProc = 1 Then '8/1/03
            .Body = DLookup("[EMailBody]", "[tblEMailBody-IMCU]")
            intAtt = DLookup("[Attachfile]", "[tblEMailBody-IMCU]")
        Else
            .Body = DLookup("[EMailBody]", "[tblEMailBody]")
            intAtt = DLookup("[Attachfile]", "[tblEMailBody]")
        End If

        .Attachments.Add (strfile)

        If intAtt = True Then
            DoCmd.OpenForm "frmFileLocations", , , , , acHidden
            strF2 = [Forms]![frmFileLocations].[Attachment]
            'strF2 = "'" & strF2 & "'"
            .Attachments.Add (strF2)
        End If
        '.Body = strMessage

        If blnKnownRecipient = True Then
            .Send
        Else
            .Display
        End If
    End With

    Set olMail = Nothing
    'olApp.Quit
    'Set olApp = Nothing

SendEMail_Exit:
    Exit Function

SendErr:
    If Err.Number = 3021 Then
        MsgBox "No Distribution List has been set up for the propery", vbCritical, "Missing Info"
    Else
        strmsg = Err.Description
        MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source
        SendMail = False
        Resume SendEMail_Exit
    End If

End Function


John





Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2000 Contacts into Access MWiseman Access VBA 5 January 27th, 2005 02:32 PM
Outlook 2000 errors byron Pro VB.NET 2002/2003 3 December 1st, 2003 10:17 AM
Outlook 2000 errors byron VB.NET 2002/2003 Basics 0 August 28th, 2003 09:08 AM
Outlook 2000 - Macro trouble brunette VB How-To 0 August 22nd, 2003 06:40 AM
Outlook 2000 Automation byron Pro VB 6 4 July 10th, 2003 01:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.