473,320 Members | 1,957 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,320 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 5310
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.