473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Not able to display all record in email

I am using the below code to display all the record based on a condition, but it is displaying the last record.

Expand|Select|Wrap|Line Numbers
  1.                Dim objOutlook As Outlook.Application
  2.                Dim objOutlookMsg As Outlook.MailItem
  3.                Dim objOutlookRecip As Outlook.Recipient
  4.                Dim objOutlookAttach As Outlook.Attachment
  5.                Dim PLT As New ADODB.Connection
  6.                Dim MyRecSet As New ADODB.Recordset
  7.  
  8.                Set PLT = New ADODB.Connection
  9.                PLT.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=H:\ActionItem.mdb;"
  10.                PLT.Open
  11.                Set MyRecSet.ActiveConnection = PLT
  12.                MyRecSet.CursorLocation = adUseClient
  13.                MyRecSet.Open ("SELECT New_Action_Item,Assignee,Status,Description,Start_Date,End_Date,Action_ID FROM Action_item where status = 'open' ")
  14. Set objMessage = CreateObject("CDO.Message")
  15.  
  16.           ' Create the Outlook session.
  17.           Set objOutlook = CreateObject("Outlook.Application")
  18.  
  19.           ' Create the message.
  20.           Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
  21.  
  22.           With objOutlookMsg
  23.               ' Add the To recipient(s) to the message.
  24.               Set objOutlookRecip = .Recipients.Add("xyz.com")
  25.               objOutlookRecip.Type = olTo
  26.  
  27.              ' Set the Subject, Body, and Importance of the message.
  28.              .Subject = "Action Item From Team Meeting"
  29.             Do While Not MyRecSet.EOF
  30.  
  31.              .Body = objMessage.TextBody & MyRecSet(0) & "     " & MyRecSet(1) & "    " & MyRecSet(2) & "   " & MyRecSet(3) & "   " & MyRecSet(4) & "    " & MyRecSet(5) & "     " & MyRecSet(6)
  32.  
  33.             MyRecSet.MoveNext
  34.             Loop
  35.  
  36.              ' Resolve each Recipient's name.
  37.              For Each objOutlookRecip In .Recipients
  38.                  objOutlookRecip.Resolve
  39.              Next
  40.  
  41.              ' Should we display the message before sending?
  42.  
  43.                  '.Save
  44.                  .Send
  45.  
  46.           End With
  47.           Set objOutlook = Nothing
May 14 '14 #1
1 1149
Rabbit
12,516 Expert Mod 8TB
That's because you keep overwriting the Body of your email instead of appending to it. And for some reason you're using 2 different message objects.
May 14 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Michael Charney | last post by:
I have a form where records are entered. I have turned off the built in record control. I created buttons to advance and go back through the records as well as an add new record button, but I also...
0
by: Carl | last post by:
I have a main form with navigation buttons on it and a label showing for example Record 1 of 15 using recordsetclone on it and eveything works fine. When I move through the records the record...
4
by: mahadevk | last post by:
hi, friends pl help me, how to display record count in a report for a grouped records
1
by: beemomo | last post by:
hi everyone! i need to display all the data of a record in a form by selecting the value of combobox. for example when i select a Project_No display in combobox, the correspondence data of that...
1
kamill
by: kamill | last post by:
Dear Friends, I am using a php mail function, with this script i am sending mail to customer of my client. Script id doing well with other domain but with same domain emails script is unable to...
2
by: erniemack | last post by:
I am using a combobox lookup on one form and would like to use the value returned from that lookup to display a record on another form. Here is the select statement: SELECT tblJob.JobNumber,...
2
by: Swapnil Mestry | last post by:
I want to display record in this format: PATIENT_CODE,gender,Malecount,femalecount Select PATIENT_CODE,gender,count(*) From BABY_MASTER Where Patient_Code='KBB-04-2010-96' group by...
1
by: calv | last post by:
Hi, I am using visual studio 2005 for a project and i am using ADODB connection to connect to the sqlite database. I would like to know how do i read and display record from the sqlite...
3
by: dmarco | last post by:
I have linked the Outlook folder on my Access 2013 database. In Access there is no way to display an email so, I would like to display the current email calling MS Outlook but I did not find any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.