473,769 Members | 6,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding multiple attachments from access into outlook

153 New Member
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 DatabaseReferen ceNumber = " _
& recSet1("Databa seReferenceNumb er2")

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 outOutlookAttac h 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

recSet6.Close
'MsgBox "All done...", vbMsgBoxSetFore ground
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.MailIte m
Set outMail = outObj.CreateIt em(olMailItem)
' 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 outOutlookAttac h = outMail.Attachm ents.Add(outApp t)
recSet8.MoveNex t
Loop
outMail.Body = _
"HI"
outMail.Send
recSet8, as you can see from the beginning code, is where I save all the necessary information...s o I have this outOutlookAttac h 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 5364
Kosmos
153 New Member
okay so I have a new version of this that goes like:

' Send a message to your new contact.
Dim outMail As Outlook.MailIte m
Set outMail = outObj.CreateIt em(olMailItem)
Set myattachments = outMail.Attachm ents
' 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 outOutlookAttac h = outMail.Attachm ents.Add(outApp t)
myattachments.A dd (outAppt)
recSet8.MoveNex t
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 New Member
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 New Member
In continuous follow up on my own question lol...does outlook.attachm ents require a "real" file and outlook.attachm ent require an embeded file?
Jan 3 '07 #4
maxamis4
295 Recognized Expert Contributor
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 New Member
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.ht ml
Jan 5 '07 #6

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

Similar topics

12
4733
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) My newsaccount wasn't working anymore until yesterday, so I'll try again. Question is: I know it is possible to send email with Access, but can one also automate the attachments?
5
15935
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. Public Function PrintPDFemail2() ' This will create the PDF if the report is setup for it DoCmd.OpenReport "rptJobItemStat", acViewNormal
1
1936
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. There I can review and decide which ones to send. The program was working fine the other day and then decided to stop with the following message: Can't create file: filename.doc. Right-click the folder you want to create the file in, and then...
0
1022
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 point its a POC app, so I am being encouraged to keep it simple. I figure I could use a Webservice and SOAP for this, or perhaps a Windows Service (I have more experience writing winservices than webservices). I have a couple of questions I...
0
2879
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. When the component is run on the exchange 2003 server a wizard gui is automatically started which wants to install Outlook 2003. The component is using mapi to access the default inbox. What do i need to do to convert this component to run on...
2
3673
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 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...
2
5130
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: I'm using Redemption to create a SafeItem, and Microsoft Outlook to create a mail item. When an attachment is added, it does get sent to the recipient, but the mail item, when first displayed, doesn't appear to include the attachment. It's there...
1
3972
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 drafts folder using VBA, although only one (1) file attachment from the specified folder is added to the email. How do I iterate through the contents of the file folder and get them all to be added as attachments ?? Any sample code would be GREATLY...
4
5157
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 people's PCs as to not get all the Outlook security prompts. Here's the problem: Half are using Outlook 2003, the other half is using Outlook 2007, and 1 is using Outlook XP. I am using Outlook 2007, so my reference is set to use Microsoft...
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
10216
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
10049
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...
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
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
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...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
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.