473,493 Members | 4,355 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to send multiple appointments to Outlook

135 New Member
I am currently using this code to send an appointment to Outlook. It sends the info to a form called "frmAppointments" and then to Outlook. This code works great to send the record that is in focus. I would like to be able to have the ability to send multiple records as appointments. How do I do more than one at a time?
Expand|Select|Wrap|Line Numbers
  1. Form_frmAppointments!ApptDate = [Form_Maintenance Subform3].[Next Maintenance]
  2. 'Form_frmAppointments!ApptTime = Me![Sample Run Time]
  3. Form_frmAppointments!Appt = Me.Text80
  4. Form_frmAppointments!ApptReminder = True
  5.  
  6.  
  7.  
  8. ' Save record first to be sure required fields are filled.
  9. DoCmd.RunCommand acCmdSaveRecord
  10. ' Exit the procedure if appointment has been added to Outlook.
  11.  
  12. Dim outobj As Outlook.Application
  13. Dim outappt As Outlook.AppointmentItem
  14. Set outobj = CreateObject("outlook.application")
  15. Set outappt = outobj.CreateItem(olAppointmentItem)
  16. With outappt
  17. .Start = Form_frmAppointments!ApptDate & " " & Form_frmAppointments!ApptTime
  18. .Duration = Form_frmAppointments!ApptLength
  19. .Subject = Form_frmAppointments!Appt
  20. .Categories = "Maintenance"
  21. If Not IsNull(Form_frmAppointments!ApptNotes) Then .Body = Form_frmAppointments!ApptNotes
  22. If Not IsNull(Form_frmAppointments!ApptLocation) Then .Location = _
  23. Form_frmAppointments!ApptLocation
  24. If Form_frmAppointments!ApptReminder Then
  25. .ReminderMinutesBeforeStart = Form_frmAppointments!ReminderMinutes
  26. .ReminderSet = True
  27. End If
  28. .Save
  29. End With
  30. ' Release the Outlook object variable.
  31. Set outobj = Nothing
  32. ' Set the AddedToOutlook flag, save the record, display a message.
  33. Form_frmAppointments!AddedToOutlook = True
  34. DoCmd.RunCommand acCmdSaveRecord
  35. MsgBox "Appointment Added!"
  36. Exit Sub
  37. AddAppt_Err:
  38. MsgBox "Error " & Err.Number & vbCrLf & Err.Description
  39. Exit Sub 
Oct 28 '10 #1
7 4164
ADezii
8,834 Recognized Expert Expert
This is just Theory, I haven't actually tested it.
  1. Create a Recordset which consists of only those Records that you wish to Send to Outlook.
  2. Loop through each Record, sending the appropriate Data by referencing the Fields in the Recordset.
  3. If you are not sure how to do this, I can point you in the right direction.
Oct 28 '10 #2
MyWaterloo
135 New Member
I have a subform that has all the maintenance records on it filtered according to the Equipment item on the main form. Right now I can click a button on the main form and send the infocus maintenance record from the subform to Outlook as an appointment. How would I loop through the record set to tell Access to send all of the filtered records on the subform to Outlook? I don't know how to create a "loop".
Oct 28 '10 #3
ADezii
8,834 Recognized Expert Expert
  1. Create a Recordset based on the Current State of the Sub-Form, as in it's Recordset Property.
  2. Loop through all the Records in the Recordset, performing some operation on each Record, in your case sending specific Data to Outlook.
  3. I created a Demo for you based on the Orders Form of the Northwind Sample Database. This Form contains a Sub-Form named Orders Subform. For any given Record in the Main Form (Orders), the Code will loop through through all related Records in the Sub-Form and Print specific Field Values.
Expand|Select|Wrap|Line Numbers
  1. Dim rst As DAO.Recordset
  2.  
  3. Set rst = Me![Orders Subform].Form.RecordsetClone
  4.     rst.MoveFirst
  5.  
  6. Debug.Print "[ProductID]", "[Quantity]", "[UnitPrice]", "[Discount]", "[ExtendedPrice]"
  7.  
  8. With rst
  9.   Do While Not .EOF
  10.     'Process Fields for Outlook here
  11.     Debug.Print ![ProductID], ![Quantity], ![UnitPrice], ![Discount], ![ExtendedPrice]
  12.       .MoveNext
  13.   Loop
  14. End With
  15.  
  16. rst.Close
  17. Set rst = Nothing
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. [ProductID]   [Quantity]    [UnitPrice]   [Discount]    [ExtendedPrice]
  2.  59            15            55            0.1           742.5 
  3.  57            5             19.5          0.1           87.75 
  4.  40            10            18.4          0.1           165.6 
  5.  11            50            21            0.1           945 
Oct 28 '10 #4
MyWaterloo
135 New Member
ADezii, thanks. I guess I am just not quite understanding what I am suppose to do with this code. Is it suppose to work in conjunction with the code to send an appointment to Outlook? I placed this code you gave me behind a button on the Orders form of the Northwind database, but nothing happens when I click it. Thanks for the puzzle piece I just don't know where to put it. =-)
Oct 29 '10 #5
ADezii
8,834 Recognized Expert Expert
When I get a chance, I'll try to Merge this Code with your Outlook Code to give you some idea as to how you can process the Records in the Sub-Form. The General Idea is as follows:
Expand|Select|Wrap|Line Numbers
  1. Dim outobj As Outlook.Application
  2. Dim outappt As Outlook.AppointmentItem
  3. Set outobj = CreateObject("outlook.application")
  4. Set outappt = outobj.CreateItem(olAppointmentItem)
  5. Dim rst As DAO.Recordset
  6.  
  7. Set rst = Me![Orders Subform].Form.RecordsetClone       'Sub-Form's Recordset
  8.     rst.MoveFirst
  9.  
  10.  
  11. With outappt
  12.   Do While Not rst.EOF      'Process Records in the Recordset (Sub-Form)
  13.     .Start = rst!ApptDate & " " & rst!ApptTime
  14.     .duration = rst!ApptLength
  15.     .Subject = rst!Appt
  16.     Categories = "Maintenance"
  17.       If Not IsNull(rst!ApptNotes) Then .Body = rst!ApptNotes
  18.       If Not IsNull(rst!ApptLocation) Then .Location = rst!ApptLocation
  19.       If rst!ApptReminder Then
  20.         .ReminderMinutesBeforeStart = rst!ReminderMinutes
  21.         .ReminderSet = True
  22.       End If
  23.     .Save
  24.     rst.MoveNext        'Move to the Next Record
  25.   Loop
  26. End With
  27.  
  28. ' Release the Outlook object variable.
  29. Set outobj = Nothing
  30.  
  31. rst.Close
  32. Set rst = Nothing
Oct 29 '10 #6
MyWaterloo
135 New Member
"When I get a chance, I'll try to Merge this Code with your Outlook Code"... Thanks. I see on line #25 is where you put "loop". I don't believe I have ever used the loop function before. I am very interested in seeing how it would work with my actual project and then hopefully from that be able to know how to use it in other areas. Thank You.
Oct 30 '10 #7
MyWaterloo
135 New Member
I think I can better articulate what I would like to see happen. I have a maintenance database with a main form based on equipment and a subform showing all the maintenance done to the specific equipment. I am currently able to send an appointment to outlook for one record of the subform at a time by clicking a button on the main form with my send to outlook code behind it. The record is first passed to a form call frmAppointments and then to Outlook. Instead of having to select each record and then send it, I would like to be able to send all the records that are for the month with just one click. Hope this helps.
Oct 30 '10 #8

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

Similar topics

40
11779
by: ian | last post by:
Hi, I'm a newbie (oh no I can here you say.... another one...) How can I get Python to send emails using the default windows email client (eg outlook express)? I thought I could just do the...
0
1242
by: CS | last post by:
Dear all, I would like to know whether it is possible to send multiple files in 1 fax? I noticed from some sample code, I can only specify 1 faxdocument.body in the code. Is there a workaround?...
9
12899
by: trint | last post by:
Instead of just sending one document at a time, I need to send multiple documents as a print job because our laserprinter will only stack and staple one printjob it receives at a time. I need to...
6
3529
by: Barkster | last post by:
I'm trying to send using outlook but I get an error on the directcast line if I don't have outlook open. Works fine if it is open. What do I need to do to be able to send without having outlook...
4
7277
by: roni | last post by:
i dont like to use ocx controlx. is there new dll for vb.net that do the job ? or newer code, to send email throught outlook express.
2
1466
by: Senthilkumar | last post by:
Hi, I would like to send mail using Outlook or Outlook Express my .net program which is written using vb.net . When ever a new record of particular type is added, i would like to send an...
0
1267
by: Tidan | last post by:
Hi, I would like to send mail using Outlook Express my .net program which is written using vb.net 2.0. When ever a new record of particular type is added, i would like to send an automatic mail...
0
1177
by: Bibin | last post by:
I want to send email via Outlook Express and not by Outlook in VB.NET (windows application). I also want to attach files with the email. The mail (in Outlook Express) needs to be displayed before...
1
1746
by: kashib | last post by:
What I am looking for is a C# example that can send multiple documents of different formats (eg pdf, doc, docx, jpeg etc)to the printer as one print job, I am not sure of the best approach. Can you...
11
17702
by: londres9b | last post by:
I want to send multiple emails from php with one unique script. The emails are from a mysql database table. How can I achieve this?
0
7118
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
6980
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7192
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6862
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
5452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.