Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9020061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:55:10+00:00 2026-06-16T04:55:10+00:00

I want to write all the records in a query to an e-mail. This

  • 0

I want to write all the records in a query to an e-mail.

This writes the first record in the query.

MyBodyText = MailList("AccountName") & "   -   " & MailList("ExpirationDate")

I know I need some kind of loop.

MailList is defined as follows

Set MailList = db.OpenRecordset("qryDateEmail")
Option Compare Database
Option Explicit

Public Function ExpirationDate()

Dim strSQL
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String
Dim MyDecision As String
Dim strReportName As String
Dim strEnroll As String
Dim strWho As String
Dim strEmail As String

Set fso = New FileSystemObject
Set MyOutlook = New Outlook.Application
Set db = CurrentDb()
Set MailList = db.OpenRecordset("qryDateEmail")

Subjectline$ = "Expiration Date" & " " & Date

Set MyMail = MyOutlook.CreateItem(olMailItem)

Do While Not MailList.EOF
    MyBodyText = MailList("AccountName") & "   -   " & MailList("ExpirationDate")
    MailList.MoveNext
Loop

MyMail.To = "" & ""
MyMail.CC = CurrentUser() & ""

MyMail.Subject = Subjectline$

MyMail.Body = MyBodyText
MyMail.Display

strEmail = Now()
strWho = CurrentUser()

Set MyMail = Nothing
Set MyOutlook = Nothing

End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:55:12+00:00Added an answer on June 16, 2026 at 4:55 am

    You could loop through the recordset, adding those values from each row to your body text.

    Untested air code:

    With MailList
        Do While Not .EOF
            MyBodyText = MyBodyText & !AccountName & _
                "   -   " & !ExpirationDate & vbCrLf
            .MoveNext
        Loop
    End With
    

    Now I see you’ve added similar code to your question. The problem is that code overwrites the value of MyBodyText each time through the loop. Append to MyBodyText each time instead of replacing the text …

    MyBodyText = MyBodyText & "new text"
    

    instead of …

    MyBodyText = "new text"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a query to select from a table all rows with
I want to write one mysql query to fetch all my table data and
I had to write a query to update all records in a table based
I'm trying write a query to find records which don't have a matching record
I want to log/write all Javascript errors to a text file whenever an error
Currently, I have: outByte.writeInt(0x49492a00); outByte.writeInt(0x08000000); But i want to be able to write all
I want to write a function that identifies all the links on a particular
I want to write a program that automatically downloads all the csv files on
All I want to do is write hello world to a QGraphicsScene in a
Basically I want to read and write to a file then save all the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.