473,414 Members | 1,954 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,414 software developers and data experts.

Adding multiple attachments from access into outlook

153 100+
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:

stSQL = "SELECT * FROM AddedToOutlook WHERE DatabaseReferenceNumber = " _
& recSet1("DatabaseReferenceNumber2")

recSet6.Open stSQL, con6, adOpenKeyset, adLockOptimistic
If recSet6.EOF Then
recSet6.AddNew

Dim objOutlookRecip As Outlook.Recipient
Dim outObj As Outlook.Application
'Dim outItem As Outlook.ContactItem
Dim outAppt As Outlook.AppointmentItem
Dim outOutlookAttach As Outlook.Attachment
'Set outItem = outObj.CreateItem(olContactItem)
Set outObj = CreateObject("outlook.application")
Set outAppt = outObj.CreateItem(olAppointmentItem)
With recSet8
.AddNew
.Fields("Start") = recSet1.Fields("NotificationDate2") _
& " " & recSet1.Fields("ApptTime2")
.Fields("Subject") = "Contract Notification/End" & " " _
& recSet1.Fields("DatabaseReferenceNumber2") _
& " " & recSet1.Fields("Vendor2")
.Fields("Body") = "Contract Notification/End" & " " _
& recSet1.Fields("DatabaseReferenceNumber2") _
& " " & recSet1.Fields("Vendor2")
.Fields("ReminderMinutesBeforeStart") = recSet1.Fields("ReminderMinutes2")
.Update
End With
With outAppt
.Start = recSet1.Fields("NotificationDate2") _
& " " & recSet1.Fields("ApptTime2")
.Duration = .AllDayEvent
.Subject = "Contract Notification/End" & " " _
& recSet1.Fields("DatabaseReferenceNumber2") _
& " " & recSet1.Fields("Vendor2")
.Body = "Contract Notification/End" & " " _
& recSet1.Fields("DatabaseReferenceNumber2") _
& " " & recSet1.Fields("Vendor2")
.ReminderMinutesBeforeStart = recSet1.Fields("ReminderMinutes2")
.ReminderSet = True
.RequiredAttendees = "JPollard@phcs.com"
.Save
End With

'DoCmd.RunCommand acCmdSaveRecord
recSet6.Fields("AddedToOutlook") = True
recSet6.Fields("DatabaseReferenceNumber") = recSet1.Fields("DatabaseReferenceNumber2")
recSet6.Update
End If

recSet6.Close
'MsgBox "All done...", vbMsgBoxSetForeground
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 it is not pertinent to this question because it works...The problem is arising here:

' Send a message to your new contact.
Dim outMail As Outlook.MailItem
Set outMail = outObj.CreateItem(olMailItem)
' Fill out & send message...
outMail.To = recSet8.Fields("RequiredAttendees")
outMail.Subject = "Contract Notification/End..."
recSet8.MoveFirst
Do Until recSet8.EOF
outAppt.Start = recSet8.Fields("Start")
outAppt.Duration = 15
outAppt.Subject = recSet8.Fields("Subject")
outAppt.Body = recSet8.Fields("Body")
outAppt.ReminderMinutesBeforeStart = recSet8.Fields("ReminderMinutesBeforeStart")
outAppt.ReminderSet = True
outAppt.RequiredAttendees = recSet8.Fields("RequiredAttendees")
Set outOutlookAttach = outMail.Attachments.Add(outAppt)
recSet8.MoveNext
Loop
outMail.Body = _
"HI"
outMail.Send
recSet8, as you can see from the beginning code, is where I save all the necessary information...so I have this outOutlookAttach which I declared as an attachment (perhaps I need to declare as attachments but I could get that to work either) anyways I have it go through this loop but instead of returning the five results that it should (since there are five results in the table for this particular program at this point in time...but this number varies) it returns the last result in the email...but 5 times....which doesn't seem to make sense since if it is adding something every time, I should get an email with five different appointments or at least an email with just the last appointment....Can anyone understand what's going on here and how I can add multiple attachments from Access into Outlook? Your help would be greatly appreciated.
Jan 2 '07 #1
5 5326
Kosmos
153 100+
okay so I have a new version of this that goes like:

' Send a message to your new contact.
Dim outMail As Outlook.MailItem
Set outMail = outObj.CreateItem(olMailItem)
Set myattachments = outMail.Attachments
' Fill out & send message...
outMail.To = recSet8.Fields("RequiredAttendees")
outMail.Subject = "Contract Notification/End..."
recSet8.MoveFirst
Do Until recSet8.EOF
outAppt.Start = recSet8.Fields("Start")
outAppt.Duration = 15
outAppt.Subject = recSet8.Fields("Subject")
outAppt.Body = recSet8.Fields("Body")
outAppt.ReminderMinutesBeforeStart = recSet8.Fields("ReminderMinutesBeforeStart")
outAppt.ReminderSet = True
outAppt.RequiredAttendees = recSet8.Fields("RequiredAttendees")
'Set outOutlookAttach = outMail.Attachments.Add(outAppt)
myattachments.Add (outAppt)
recSet8.MoveNext
Loop
outMail.Body = _
"HI"
outMail.Send
but this still doesn't seem to work. It seems that this would work with multiple files but it's looking for a file extension...is there some file extension for the current temporary project for each declared value?
Jan 2 '07 #2
Kosmos
153 100+
just trying to bring this back up on the list in case anyone has any suggestions...I worked all day yeasterday on this little problem and can't seem to figure it out
Jan 3 '07 #3
Kosmos
153 100+
In continuous follow up on my own question lol...does outlook.attachments require a "real" file and outlook.attachment require an embeded file?
Jan 3 '07 #4
maxamis4
295 Expert 100+
This question I can say yes too. I am looking at your orginial post as well. Have you also tried www.utteraccess.com. Those guys have a code archive that might have what you need.
Jan 5 '07 #5
Kosmos
153 100+
Thanks...I have posted a new version of the code, as well...I generally make it a point not to double post but nobody had gotten back to me on this question :( ....but thank you I will check that other forum out...my newer code is here: http://www.thescripts.com/forum/thread584506.html
Jan 5 '07 #6

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

Similar topics

12
by: Arno R | last post by:
Hi all, This is a repost of a message posted at october 6. The answer I got was about MapiMessages.AttachmentIndex. I think I need the MSMAPI32.OCX to use this. (I don't have this file on my PC)...
5
by: paii, Ron | last post by:
How do I setup a email with attachment for preview but require the user to push the SEND button in Outlook. I have the following function but it sends the email without the sender ever seeing it. ...
1
by: Peter Wullems | last post by:
I use C# to parse incoming emails for a predefined type and structure of message content and construct replies automatically, attach a file and place the generated emails in the drafts folder. ...
0
by: DC | last post by:
I have a requirement for an application that, through drag and drop, takes the email attachments from Outlook 2000 desktop clients and sends them in binary format to a SQL Server database. At this...
0
by: fish | last post by:
Hi, I have a VB.net application that will save attachments to a directory on my local pc. I need to run this component on our exchange 2003 server and also save the attachments to a local DIR. ...
2
by: Kosmos | last post by:
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...
2
by: dlesandrini | last post by:
Now that I have my rant about Google Search out of the way, I can ask my question. Someone must have noticed this, but since I can't Google the Access groups about it, I'll have to just ask: ...
1
by: rmarek | last post by:
I need to create an Outlook email from within Access that adds all the contents of a specific file folder as attachments. I have been able to get the email created and drop it into the Outlook...
4
by: musicloverlch | last post by:
Hi all, I have a database being used by 30 people and is split between the backend and frontend. The database has the ability to send e-mails through Outlook and I have even put Redemption on...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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:
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
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...
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...
0
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...

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.