Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    1

    Question Unanswered: sending e-mail from acess, using a query as mailing list.

    Hi there,

    just wondering if any one can offer me any advice, i have built a acess database, althouhg i now want to be able to send e-mails directly from acess, i am using send object, but this is sent using pre set e-mail adresses, i want it to automatily add all the e-mail adress that are in a select query and send it to all those people, as BCC:

    Can any one help??

    Cheers
    Ben

  2. #2
    Join Date
    Jan 2004
    Location
    austin
    Posts
    146
    try this....

    make sure you set a reference to Microsoft Outlook.

    Code:
    Sub email_adrs()
    
    Dim rsmytable As Recordset
    Dim i1, rcount As String
    Dim i As Integer
    Dim oMailApp As Outlook.Application
    Dim oMail As Outlook.MailItem
    
            Set rsmytable = New ADODB.Recordset
                rsmytable.ActiveConnection = CurrentProject.Connection
                rsmytable.Open "QRY_EMAIL_ADRS", , adOpenKeyset, adLockOptimistic, _
                adCmdTable
    
                    rcount = rsmytable.RecordCount
    
                    For i = 1 To rcount
                        i1 = rsmytable.Fields("UserName")
                           
                            DoCmd.SetWarnings False
             
                            Set oMailApp = CreateObject("Outlook.Application")
                            Set oMail = oMailApp.CreateItem(olMailItem)
                            With oMail
                                .TO = "name@email"
                                .BCC = i1
                                .Subject = "test email"
                                .Body = vbCrLf & vbCrLf & " test "
                                 .Display
                                '.Send
                            End With
    
                      Next
    
              rsmytable.Close
              
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •