473,513 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automating adding attachments to email based on MS Access query

2 New Member
Hello,

I have a question that hopefully someone may be able to help me with. I’m trying to come up with a solution by using a VBA code or some other method. I’ve tried googling what I’m trying to do with a few posts that are similar to what I’m trying to do. https://bytes.com/topic/access/answers/943464-send-access-report-body-outlook-email

Currently I have a manual process that I’m trying to automate. We have a MS Access 2010 query that shows a filtered view from a master list of chemicals to give me a site specific list of chemicals that are in use. From that list, I manually copy and paste a single PDF file relevant to each in use chemical into an email and send that email to a couple of email address.

I’m trying to figure out a way to automate this process, as we have a number of different sites which use a varied list chemicals. I’d like to see if I can use some code based off content from a query to pull some PDF files into an email and then send it.

I do already have a lovely bit of VBA code that uses .AddAttachment to be able to pull external files into an email so that it can be sent. The difference is for what the existing code is used for there is a consistent set of files each and every time. Because for what I’m trying to design this list of chemicals is inconsistent I’m wondering how to approach it.

I can add a field into the database for the constant URL location of where the PDF is located which might be useful.

Here is my existing code that works where things are consistent I’ve tried to trim it where possible imagine multiple lines of 'msgXX.AddAttachment ("Z:\Z.pdf"),

Expand|Select|Wrap|Line Numbers
  1. Dim msgXX
  2. Set msgXX = CreateObject("CDO.Message")
  3. Set msgXX.Configuration = cdoConfig
  4. msgXX.AddAttachment ("Y:\ZZZ.pdf")
  5. msgXX.To = "barry@bbq.com.au, reception@bbq.com.au"
  6. msgXX.From = "boris@bbq.com.au"
  7. msgXX.Subject = "ZZZ Site Chemical list"
  8. msgXX.TextBody = "Hello." & vbCrLf & " " & vbCrLf & "Automated update of compliance update for this month."
  9. msgXX.send
  10.  
Kind Regards
Oct 12 '16 #1
2 763
jforbes
1,107 Recognized Expert Top Contributor
Here is an example of someone that did something very similar, How to attach several files to e-mail message (objMessage.AddAttachment)

It opens a saved Query and attaches all the files that are returned by the Query. You might want get your list a different way, but the basics of attaching multiple documents are pretty much the same.
Oct 12 '16 #2
Scoricco
2 New Member
Thanks a bunch. I'll check it out.
Oct 12 '16 #3

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

Similar topics

1
4128
by: Devonish | last post by:
I am composing an email with Access VB and then sending it from within Access. Everything works correctly (the email actually goes!) but Outlook ask some irritating questions that the user is...
10
24351
by: Mike Charney | last post by:
Is there a simple way to send SMTP email from Access VBA? Mike m charney at dunlap hospital dot org
1
2850
by: mike11d11 | last post by:
If someone could help me, I need to be able to send attachments from my access database that I have created. This database runs queries then generates a report off the queries from underlying...
4
7698
by: VoodooFrog | last post by:
I am trying to run the following code as a simple test of adding an attachment through access 2007: Dim rsJob As DAO.Recordset2 Dim rsChild As DAO.Recordset2 Dim field As Field2 ...
1
5296
by: starke1120 | last post by:
Is there a way to open a form based on query type.. Example.. If a certain query result is 1 then open the form to this result.. If the query results are NULL or 0 results, then open open for...
6
4373
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
1
2038
by: TommyGunn | last post by:
Hi everyone, Is there anyway to automatically put Access data into Mail Merge in an existing Word doc with content? I have bits and pieces of this done, but I can't seem to put it all together....
0
1748
by: micarl | last post by:
I'm trying to two two things through Access to Outlook based on a query and selections made on a form. Firstly, i'd like to create an email based on the selections made on a form. Secondly...
0
2720
by: uno7031 | last post by:
Help Please!!! Adding 5 Days to another Date in an access query Good Morning, Help please…. I am new to access and trying to write a query that will add 5 days between a RecDate and a...
8
13992
by: Weise | last post by:
Hello again , well I have pretty much completed my project but have a small problem in regards to sending email's based on a Query. I have a Query that returns results based on due date. This is...
0
7260
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
7160
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...
1
7099
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
7525
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
5685
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,...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
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 ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
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.