Results 1 to 4 of 4

Thread: send emails

  1. #1
    Join Date
    Sep 2008
    Posts
    13

    Unanswered: send emails

    Hi,
    Hope everyone is doing good.
    this is my first post in the forum and i find it great. i have a database that i use to send mass emails to agents that have cases on thier queue basiclly i run just a macro and macro run a function than emails start sending through outlook that should be open, everything works fine and never have a problem, now what i would like to do is to send mass email in HTML format using ASP, below is the code i use in access.

    Thanks.
    ____________________________
    Function SEmail()

    On Error GoTo ErrorHandler

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim Outlook As Outlook.Application
    Dim Email As Outlook.MailItem
    Dim sSubject As String
    Dim sBody As String
    Dim fso As FileSystemObject
    Dim Body As TextStream
    Dim BodyText As String

    'set Outlook
    Set Outlook = New Outlook.Application

    'set up the database and query connections
    Set db = CurrentDb()

    'warnings OFF
    DoCmd.SetWarnings False

    'clear working table
    Call DeleteTable("tSendEmails")

    'warnings OFF
    DoCmd.SetWarnings False

    'add data to working table
    DoCmd.OpenQuery "qaSendEmails"

    'warnings ON
    DoCmd.SetWarnings True

    'set query/recordset
    Set rs = db.OpenRecordset("tSendEmails", dbOpenDynaset)

    'loop through our list of addresses,
    'adding them to e-mails and sending them.
    Do Until rs.EOF

    'create the e-mail
    Set Email = Outlook.CreateItem(olMailItem)

    'address the e-mail
    Email.To = rs("Email")

    'subject of the e-mail
    Email.Subject = "Case on Your Queue"

    'body of the e-mail message
    Email.Body = "Dear " & VBA.Trim(rs("AgentName")) & ":"
    Email.Body = Email.Body & vbCrLf
    Email.Body = Email.Body & vbCrLf
    Email.Body = Email.Body & EmailText(8)
    Email.Body = Email.Body & vbCrLf
    Email.Body = Email.Body & vbCrLf
    Email.Body = Email.Body & rs("CaseID")
    Email.Body = Email.Body & vbCrLf
    Email.Body = Email.Body & vbCrLf
    Email.Body = Email.Body & EmailText(9)

    'flag e-mail as confidential
    Email.Sensitivity = olConfidential

    'flag e-mail as read receipt requested
    'Email.ReadReceiptRequested = True

    'send e-mail
    Email.Send

    Out:
    'move to the next one
    rs.MoveNext

    Loop

    MsgBox "Email Process Complete"

    rs.Close
    db.Close

    Set Email = Nothing
    Set Outlook = Nothing
    Set rs = Nothing
    Set db = Nothing

    Exit Function

    ErrorHandler:
    'Error handler will be used to flag job table when Outlook cannot send an
    'e-mail because e-mail address is invalid

    rs.Edit
    rs("Invalid") = True
    rs.Update
    Resume Out

    End Function

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Sep 2008
    Posts
    13
    I want to do it in Access First, knowing it in ASP that my future plan to create webpage to send mass emails

  4. #4
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Here's a handly link for sending a single e-mail and of course something like this could be done within a recordset loop to send multiple e-mails perhaps up to there is a timeout:

    ASP Sending e-mail with CDOSYS
    http://www.w3schools.com/asp/asp_send_email.asp
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

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