I have an Access Database that is used as an ordering system. At the minute, when the user hits the re-order button, the details required are passed to a sub which then passes these details into the body of an email and sends it. This works great but the problem is, one email equals one order. One of my users has now requested that multiple orders can be made on one click of the button. I have added a check box to the form and ideally I would like to loop through the table and add the info to the body of the email where the check box is marked true. Is this possible?
3 2897
Yes, this should be possible but will need much greater detail. Table structure, Field Types, sample Data, E-Mail Client...
Assuming you're using Outlook and already have an idea of how to generate the body of the e-mail...
Sure, using Ron de Bruin's Outlook code for Excel and retrofitting it to Access: http://www.rondebruin.nl/win/s1/outlook/bmail4.htm
The basic steps would be: - Include reference to Microsoft Outlook Object Library in the Access VBA IDE.
- Augment Ron's Mail_small_Text_Outlook function to include strBody in the function's arguments, so you can create the body outside of the mail function.
- Public Sub mailSend(Optional strTo As String, Optional strCC As String, Optional strBBC As String, _
-
Optional strSubject As String, Optional strBody As String, Optional varAttachmentFilepath As Variant, Optional boolSend As Boolean, _
-
Optional boolHTMLBody As Boolean, Optional strSendFromEmail As String)
-
' send an e-mail message (and optional attachment) via outlook
-
' adapted from code by ron de bruin of www.rondebruin.nl
-
-
Dim objOutlook As Object
-
' object for outlook application
-
-
Dim objMessage As Object
-
' object for outlook mail message
-
-
Set objOutlook = CreateObject("Outlook.Application")
-
' reference/open outlook
-
-
Set objMessage = objOutlook.CreateItem(0)
-
' create a new outlook mail message
-
-
With objMessage
-
' working with the new outlook mail message, ...
-
-
.To = strTo$
-
' set the recipients
-
-
.CC = strCC$
-
' set the carbon copy recipients
-
-
.BCC = strBCC$
-
' set the blind carbon copy recipients
-
-
.Subject = strSubject$
-
' set the subject
-
-
If boolHTMLBody = True Then
-
' if user requests to have the e-mail sent as an html e-mail, ...
-
-
.BodyFormat = olFormatHTML
-
' set the body format of the e-mail to html
-
-
.HTMLBody = strBody$
-
' set htmlbody of e-mail
-
-
Else
-
' if user does not want to have the e-mail sent as an html e-mail, ...
-
-
.Body = strBody$
-
' set the body
-
-
End If
-
-
If strSendFromEmail$ <> vbNullString Then .SentOnBehalfOfName = strSendFromEmail$
-
' if user provided a from e-mail, set the sentonbehalfof e-mail
-
-
If IsArray(varAttachmentFilepath) Then
-
' if the attachment filepath is an array, ...
-
-
If IsEmpty(varAttachmentFilepath) = False Then
-
' if the attachment filepath array is not empty, ...
-
-
For Each objAttachmentFilepath In varAttachmentFilepath
-
' looping through each attachment filepath in the array, ...
-
-
If CStr(objAttachmentFilepath) <> vbNullString Then
-
' if the attachment filepath, converted to a string, is not blank, ...
-
-
.Attachments.Add objAttachmentFilepath
-
' add the attachment filepath to the array
-
-
End If
-
-
Next objAttachmentFilepath
-
' continue looping through the attachment filepath array
-
-
End If
-
-
Else
-
' if the attachment filepath is not an array, ...
-
-
If IsMissing(varAttachmentFilepath) = False Then
-
' if an attachment filepath is possibly provided, ...
-
-
If varAttachmentFilepath <> vbNullString Then
-
' if an attachment filepath is provided
-
-
.Attachments.Add varAttachmentFilepath
-
' add the attachment
-
-
End If
-
-
End If
-
-
End If
-
-
If boolSend = True Then
-
' if user wants to send the messsage, ...
-
-
.Send
-
' send the message
-
-
Else
-
' if user does not want to send the message, ...
-
-
.Display
-
' display the message
-
-
End If
-
-
End With
-
-
Set objMessage = Nothing
-
' clear for memory
-
-
Set objOutlook = Nothing
-
' clear for memory
-
-
End Sub
- Create function to generate the body text from the table, query, whatever you're wanting to mail.
- Call Mail_small_Text_Outlook (or the modified mailSend), including the body generated from the 3rd step.
- Profit.
zmbd 5,501
Expert Mod 4TB
Corwin Moyne:
Poet has provided some nice code; however, it (IMHO) isn't usable for your application "as is" and will need some considerable modification.
However, if you can post the code that you are currently using to create and send your email, along with the information that ADezii has requested, I'm sure that we can provide some guidance/direction.
When you post your code please select the text and click on the [CODE/] formatting button to place the required [code] tags around it (that way the code is in the nice code box - (^_^) thnx) In general, any formatted (think table) or other code (such as SQL, etc...) should be formated this way.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: cooldv |
last post by:
i know how to replace the sign " when SUBMITTING a form in asp by this
code:
message = Replace(usermessage, "'", "''").
My problem is DISPLAYING data in an asp FORM, from an an access
database,...
|
by: RBohannon |
last post by:
I'm using Access 2000.
I currently have a report being generated using the results of a query
by form. The form used for this query is an unbound form,
frmListDialog. frmListDialog contains...
|
by: st_moose |
last post by:
I have a query that the user inputs last name of the customer and
wants the output to be a specific form (that form is the form that all
the information is entered originally). How do I set up the...
|
by: meganrobertson22 |
last post by:
hi everybody-
what is the best way to add data from one form to another?
i have 2 tables: person and contract. here are some of the fields.
table: person
personid (autonumber and primary...
|
by: abc my vclass |
last post by:
Is VS2005 debugger let me to see dataset, datatable data as table form?
I found if I watch some table or dataset variable is very very hard to see.
Is there any good tools or add-ins for debugger...
|
by: tomblower |
last post by:
Access 2000 fully updated
Three PCs manage data held on a server. They each have a front-end mdb
file linked to tables on the server and on each PC.
A problem has arisen over the following line...
|
by: pd123 |
last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error "
The name 'Peter' is...
|
by: Tom |
last post by:
Hello,
I have a database of employee data in access and I am trying to create
a form with combo boxes for criteria (ex. gender, office, position,
etc.) that let the user select criteria from...
|
by: rahul more |
last post by:
My aim is - Access data from table and show it into a form's textboxes , comboxes for edition of data.
I am using listview. I am selecting particular row of listview by clicking on that row and...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |