473,769 Members | 7,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding multiple email appointment attachments to a single email from ms access

153 New Member
Alright so I've got this Outlook code written in VBA in Access. The first part, which works, records information about appointment times based on the required days before notification of certain contracts and then it adds them to the outlook calendar of the current user. This code works and is nested within a bunch of if statements because it only needs to trap certain appointments. The table I create with this code is later used to attempt to create an email that sends out multiple appointments by means of adding an attachment, this is where I am having trouble. First I will post the code that works and then the code that does not work.

This is the code that works:

[PHP] stSQL = "SELECT * FROM AddedToOutlook WHERE DatabaseReferen ceNumber = " _
& recSet1("Databa seReferenceNumb er2")
' (This beginning part is just checking another table to see if these appointments have already been added to Outlook.)

recSet6.Open stSQL, con6, adOpenKeyset, adLockOptimisti c
If recSet6.EOF Then
recSet6.AddNew

Dim objOutlookRecip As Outlook.Recipie nt
Dim outObj As Outlook.Applica tion
'Dim outItem As Outlook.Contact Item
Dim outAppt As Outlook.Appoint mentItem
Dim myattachments As Outlook.Attachm ent
'Set outItem = outObj.CreateIt em(olContactIte m)
Set outObj = CreateObject("o utlook.applicat ion")
Set outAppt = outObj.CreateIt em(olAppointmen tItem)
With recSet8
.AddNew
.Fields("Start" ) = recSet1.Fields( "NotificationDa te2") _
& " " & recSet1.Fields( "ApptTime2" )
.Fields("Subjec t") = "Contract Notification/End" & " " _
& recSet1.Fields( "DatabaseRefere nceNumber2") _
& " " & recSet1.Fields( "Vendor2")
.Fields("Body") = "Contract Notification/End" & " " _
& recSet1.Fields( "DatabaseRefere nceNumber2") _
& " " & recSet1.Fields( "Vendor2")
.Fields("Remind erMinutesBefore Start") = recSet1.Fields( "ReminderMinute s2")
.Update
End With
With outAppt
.Start = recSet1.Fields( "NotificationDa te2") _
& " " & recSet1.Fields( "ApptTime2" )
.Duration = .AllDayEvent
.Subject = "Contract Notification/End" & " " _
& recSet1.Fields( "DatabaseRefere nceNumber2") _
& " " & recSet1.Fields( "Vendor2")
.Body = "Contract Notification/End" & " " _
& recSet1.Fields( "DatabaseRefere nceNumber2") _
& " " & recSet1.Fields( "Vendor2")
.ReminderMinute sBeforeStart = recSet1.Fields( "ReminderMinute s2")
.ReminderSet = True
.RequiredAttend ees = "JPollard@phcs. com"
.Save
End With

'DoCmd.RunComma nd acCmdSaveRecord
recSet6.Fields( "AddedToOutlook ") = True
recSet6.Fields( "DatabaseRefere nceNumber") = recSet1.Fields( "DatabaseRefere nceNumber2")
recSet6.Update
End If[/PHP]

Which is later followed by this code which does not seem to work:

[PHP]Dim outMail As Outlook.MailIte m
Set outMail = outObj.CreateIt em(olMailItem)
Dim outAppt2 As Outlook.Appoint mentItem
Set myattachments = outMail.Attachm ent
' Fill out & send message...
outMail.To = recSet8.Fields( "RequiredAttend ees")
outMail.Subject = "Contract Notification/End..."
recSet8.MoveFir st
Do Until recSet8.EOF
outAppt.Start = recSet8.Fields( "Start")
outAppt.Duratio n = 15
outAppt.Subject = recSet8.Fields( "Subject")
outAppt.Body = recSet8.Fields( "Body")
outAppt.Reminde rMinutesBeforeS tart = recSet8.Fields( "ReminderMinute sBeforeStart")
outAppt.Reminde rSet = True
outAppt.Require dAttendees = recSet8.Fields( "RequiredAttend ees")
Set outAppt2 = outAppt
' (tried putting separate code in a module but didn't work either) DoCmd.OpenModul e "modAppointment "
Set myattachments = myattachments.A dd(outAppt)
recSet8.MoveNex t
Loop
outMail.Body = _
"HI"
outMail.Send


'For Each objOutlookRecip In .Recipients
'objOutlookReci p.Resolve
'Next
' Clean up...

Set outMail = Nothing
'Set outItem = Nothing
Set outObj = Nothing
Set outAppt = Nothing[/PHP]

It seems that it is possible because an earlier version of this code was able to add five appointments but only added the last appointment in the recordset which I checked and surely it had 5 records in the table (but this number will vary based on the number of contracts that require notification within a certain number of days) but if I have 5 records...and I say move first, it seems like the only thing I'm acheiving by running this .EOF loop is counting from 1 to 5 and then multiplying the last entry by it. So that didn't make much sense.

The older version of the code can be found here:
http://www.thescripts.com/forum/thread583157.html

The code for the larger part of this program which would help you understand the context of this function can be found here:
http://www.thescripts.com/forum/thread581521.html
although I don't think this is necessary to figure out the problem...but people always like to have more code :)

Any help with this would be greatly appreciated as I have been struggling with this for a while and Microsoft does not seem to offer any help with this...nor does anyone else for that matter.

Cheers,
Kosmös
Jan 5 '07 #1
2 3672
NeoPa
32,573 Recognized Expert Moderator MVP
Kosmos,
I suspect that you will need to do some work on this before you can expect any help. As a Senior Member who has started to respond to questions yourself, you will be starting to understand the importance of how a question is asked. With such a complicated question you will need to do some work yourself finding out the problem - asking someone else to find a problem in a bunch of code that size is not reasonable - especially as you should have some idea of the problems you experience (where does it fail? What error message, if any, do you get?).
I can't tell you to redo this, but I can suggest that, if you don't, you're less likely to receive a helpful reply.
Don't forget - more is not always better.
Good luck.
-Adrian.
Jan 6 '07 #2
Kosmos
153 New Member
I really didn't think it was that much code...and besides the problem really lies in the statement where I add the appointment to myattachments (but I guess I should have clarified that a little bit better). I've done a ton of research and can't find the answer to this question. The reason I tend to post more code is that whenever I have posted a shorter question, people have tended to ask me for the full code so they could see the problem in context. Anyways I've got a busy day ahead of me, but I do apologize for posting too much code. I didn't mean for people to debug my entire code and that was entirely my fault...but it does at least give people tons of example code from which they can adapt their own code if they're searching for a similar problem.
Jan 8 '07 #3

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

Similar topics

2
2082
by: dixie | last post by:
I have a report which is printed daily. It is a list of people. A person can be put on this list for one day, which is easyily achieved from a simple form. My problem is that a person can also be put on the list for a number of days. The information that I would then have is the person,s ID, name, the first date they are on the list and the number of days they are on the list. Assuming that the dates are consecutive (although weekends...
4
2297
by: Jim M | last post by:
Two questions: 1) I have a scheduling application (Access 2002) that allows multiple staff members to edit notes on their meetings and appointments from their offices. A receptionist views a limited dataset of all of their appointments and changes the status of an appointment to "Show" as clients come in the door. She keeps a form open all day that lists that day's appointments for all staff in chronological order. Once in a while,...
1
4314
by: mal_lori | last post by:
Hello, I have basic code to Creat an Outlook appointment and add Access Data. (code below) This works to add appointments to the basic calendar in my user folder. However I wish to add it to a Calendar that resides in Public folder. Any advice or resources on how to do this? The "address" is .... Public Folders...All Public Folders...CommonRanchCalendar
1
2353
by: nabil m | last post by:
hi i have 5 checkboxes i would like to when the user click on 1 or multiple checkbox i would like to email 1 or multiple files attachments to them ex: mailMsg.Attachments.Add(myAttachment+i); but getting error: Specified cast is not valid. thank you in advance my code below: MailAttachment myAttachment0 = new MailAttachment (this.Server.MapPath("../serverForms/Auto_Form_01.pdf"),
3
2249
by: Brian Farnhill (MCP VB.NET) | last post by:
Hi, I am having some trouble using the MailMessage object to send an email with more than one attachment. I am working on a web based application where a user can submit information, along with a number of files. The information, including the file is stored in the database, and an email is sent with the information and any files that were submitted are attached. The system works fine when a user makes a submission that has no...
9
2778
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and wizards. But, I have found that trying to do something "outside the norm" adds a rather large level of complexity and/or data replication. Background I have been commissioned to create a web-based application for a client. It has a formsaunthentication...
8
3273
by: shumaker | last post by:
I'm wondering if adding an autonumber primary key will improve the performance of a multiuser access database on a network share. I have a website that lists many tips for improving performance of access, but doesn't mention primary keys. However, it seems logical to think that having no primary key means that when a user updates a record, the database has to do comparisons on multiple fields to identify the specific record being...
5
5364
by: Kosmos | last post by:
I have traveled the world and the seven seas and I have yet to come up with an answer to this question.... So I'm adding an attachment to an email from access... The following is the code: and from here I go to the end (because the other part is in an If statement and that's in a loop...once the loop's finished, I've gathered the necessary information I would paste the full function but I already have in another place on this site and...
2
2960
by: lrw0831 | last post by:
I need to link attachments to each record. Some records will have multiple attachments. I have a form with Issue_ID, description, Filepath (this is a hyperlink) and a browse button. My problem is, the attachments are not saving. The Attachments table is as follows: ID (Autonumber for the attachment) Description (memo)
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10048
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.