Hi,
I am writing a database that I want to be able to hit a button and a email generates and pulls multiple photos in a specified folder on the network and throw them in a email for me to send. The photos are .jpg
Is there a way to have multiple picture attachments? I think DoCmd.OutputTo acOutputReport only does 1 record according to a post I was reading on here earlier today. So, just wanting them all attached to the email.
Any help?
Thanks,
-Andy
Here is some code I use to attach anywhere from 2 to 40 various files to an email.
I have had to remove certain bits from the code that wouldn't make sense in this context, so if the code is broken I probably removed to much. - Public Function CreateEmail() As Boolean
-
'On Error GoTo errHandler
-
-
Dim rsFiles As DAO.Recordset
-
Set rsFiles = CurrentDb.OpenRecordset("SELECT * from tbl_ReviewCommentSheet where bChecked ORDER BY tx_TransmittalID, RID", dbOpenSnapshot, dbReadOnly)
-
-
'If nothing selected exit
-
If rsFiles.EOF Then GoTo ExitFunction
-
-
'Open outllook and start email
-
Dim oMail As Outlook.MailItem
-
Dim oApp As Outlook.Application
-
Set oApp = New Outlook.Application
-
Set oMail = oApp.CreateItem(olMailItem)
-
oMail.HTMLBody = "<H3><B>Dear Sirs</B></H3>" & _
-
"Please find enclosed our comments to the above mentioned Transmittals.<br><br>" & _
-
GetSignature 'GetSignature custom function to load users Auto-signature
-
Dim oRecipient As Outlook.Recipient
-
'Add the recipients
-
Set oRecipient = oMail.Recipients.Add("FakeName@FakeCompany.com")
-
oRecipient.Type = olTo
-
-
Set oRecipient = oMail.Recipients.Add("FakeName2@FakeCompany2.dk")
-
oRecipient.Type = olCC
-
oMail.Recipients.ResolveAll
-
-
'Loop through adding attachments
-
Dim strPath As String
-
Dim strWorkPath As String
-
strWorkPath = "G:\DATA\Comments to transmittals\LetterCreator\WorkFolder\"
-
Dim strLastTrans As String
-
Dim strSubject As String
-
strSubject = "Comments to Transmittals"
-
Do While Not rsFiles.EOF
-
If strLastTrans <> rsFiles!tx_TransmittalID Then
-
strLastTrans = rsFiles!tx_TransmittalID
-
strSubject = strSubject & " " & rsFiles!tx_TransmittalID & ","
-
End If
-
-
-
-
strPath = "G:\DATA\Comments to transmittals\Pending\" & rsFiles!tx_TransmittalID & "\"
-
'Excel first
-
oMail.Attachments.Add strPath & rsFiles!tx_ExcelFile, olByValue
-
'now pdf
-
oMail.Attachments.Add strWorkPath & rsFiles!tx_PdfFile, olByValue
-
Kill strWorkPath & rsFiles!tx_PdfFile
-
rsFiles.MoveNext
-
Loop
-
strSubject = Left(strSubject, Len(strSubject) - 1)
-
oMail.Subject = strSubject
-
oMail.Display
-
CreateEmail = True
-
-
ExitFunction:
-
rsFiles.Close
-
Set rsFiles = Nothing
-
Exit Function
-
-
exitFail:
-
On Error Resume Next
-
GoTo ExitFunction
-
-
errHandler:
-
MsgBox Err.Number & " - " & Err.Description
-
Resume exitFail
-
End Function
6 1983
There is another method for sending e-mails, I'm trying to dig up an example to show you....
zmbd 5,501
Expert Mod 4TB
I know the basic command is fairly limited.
Using automation you can do alot more: http://support.microsoft.com/kb/161088
Here's the trick... I haven't used this to send more than one attachment so you'll have to look at the code a tad.
So if we use a record set to pull the attachments then the code might be changed to something like: - 'do the open record set stuff and check to make
-
'sure there are attachments then something like
-
'modify the MS Code to read the record set
-
'
-
Do While Not zrs.EOF
-
AttachmentPath = _
-
zrs.Fields("thefieldwithattachmentpathhere")
-
Set objOutlookAttach = _
-
.Attachments.Add(AttachmentPath)
-
zrs.MoveNext
-
Loop
-
'
-
'cleanup code would follow
Once again, this is untested and based upon the code from MS from the above link.
-z
Here is some code I use to attach anywhere from 2 to 40 various files to an email.
I have had to remove certain bits from the code that wouldn't make sense in this context, so if the code is broken I probably removed to much. - Public Function CreateEmail() As Boolean
-
'On Error GoTo errHandler
-
-
Dim rsFiles As DAO.Recordset
-
Set rsFiles = CurrentDb.OpenRecordset("SELECT * from tbl_ReviewCommentSheet where bChecked ORDER BY tx_TransmittalID, RID", dbOpenSnapshot, dbReadOnly)
-
-
'If nothing selected exit
-
If rsFiles.EOF Then GoTo ExitFunction
-
-
'Open outllook and start email
-
Dim oMail As Outlook.MailItem
-
Dim oApp As Outlook.Application
-
Set oApp = New Outlook.Application
-
Set oMail = oApp.CreateItem(olMailItem)
-
oMail.HTMLBody = "<H3><B>Dear Sirs</B></H3>" & _
-
"Please find enclosed our comments to the above mentioned Transmittals.<br><br>" & _
-
GetSignature 'GetSignature custom function to load users Auto-signature
-
Dim oRecipient As Outlook.Recipient
-
'Add the recipients
-
Set oRecipient = oMail.Recipients.Add("FakeName@FakeCompany.com")
-
oRecipient.Type = olTo
-
-
Set oRecipient = oMail.Recipients.Add("FakeName2@FakeCompany2.dk")
-
oRecipient.Type = olCC
-
oMail.Recipients.ResolveAll
-
-
'Loop through adding attachments
-
Dim strPath As String
-
Dim strWorkPath As String
-
strWorkPath = "G:\DATA\Comments to transmittals\LetterCreator\WorkFolder\"
-
Dim strLastTrans As String
-
Dim strSubject As String
-
strSubject = "Comments to Transmittals"
-
Do While Not rsFiles.EOF
-
If strLastTrans <> rsFiles!tx_TransmittalID Then
-
strLastTrans = rsFiles!tx_TransmittalID
-
strSubject = strSubject & " " & rsFiles!tx_TransmittalID & ","
-
End If
-
-
-
-
strPath = "G:\DATA\Comments to transmittals\Pending\" & rsFiles!tx_TransmittalID & "\"
-
'Excel first
-
oMail.Attachments.Add strPath & rsFiles!tx_ExcelFile, olByValue
-
'now pdf
-
oMail.Attachments.Add strWorkPath & rsFiles!tx_PdfFile, olByValue
-
Kill strWorkPath & rsFiles!tx_PdfFile
-
rsFiles.MoveNext
-
Loop
-
strSubject = Left(strSubject, Len(strSubject) - 1)
-
oMail.Subject = strSubject
-
oMail.Display
-
CreateEmail = True
-
-
ExitFunction:
-
rsFiles.Close
-
Set rsFiles = Nothing
-
Exit Function
-
-
exitFail:
-
On Error Resume Next
-
GoTo ExitFunction
-
-
errHandler:
-
MsgBox Err.Number & " - " & Err.Description
-
Resume exitFail
-
End Function
Smiley - you beat me to the punch. That was the type of code I was looking for. It's the only way I know to include multiple attachments.... Thanks!
The key bit here is the - oMail.Attachments.Add strWorkPath & rsFiles!tx_PdfFile, olByValue
Using that several times you can in theory add quite alot of attachments. That said, you will probably hit the limit of how large emails your provider allows to send, or the receiver is allowed to receive.
The olByValue means that a copy of the object is being added to the email, after which you can delete the original object, even if the email isn't send yet. If you don't include this, I BELIEVE that the copy of the object isn't actually done until you call the SEND. In the code I displayed the email is displayed for the user, for the user to confirm, and manually click the send button.
To place it into the outbox immediately replace
with Sign in to post your reply or Sign up for a free account.
Similar topics
by: mary |
last post by:
I am developing an Access db which will be used by multiple users. My
questions are:
Does MS Access have problems with multiple users accessing the db at
once?
If yes, what is your solution...
|
by: intl04 |
last post by:
Are there any problems with multiple user access to the same Access
database on a shared network drive? I have 'shared' chosen for
'default open mode'. As for the record locking properties, I...
|
by: Mega1 |
last post by:
is this possable to send more than 1 report in one email
|
by: CountDraculla |
last post by:
Fixing Multiple Database bug in adoDB
popular data access layer for php, adoDB can support multiple databases
from different provider at time, but not from same provider. what I
mean is if you...
|
by: judelakmal |
last post by:
I have an application written in vb 6.0 application. It connects multiple MS Access databases sometimes. I would like to know is will this effects the performance of the application.
|
by: ttamilvanan81 |
last post by:
Hai, am using the Email function with Attachments in Vb and Access Forms. The Emial function is working. Then how to attach the file with my mail. there is any Browse control is there.
anybody...
|
by: majahops via WebmasterKB.com |
last post by:
When I click "save" after adding a new record (which contains, among other
fields, the person's email address), I want an email to automatically be sent
to that person (at the email that is in the...
|
by: Jyo |
last post by:
Hi All!
I have problem regarding multiple file attachment. Can any one help
regarding script like gmail provides for attach a file with remove
link ? Also please note that this code should...
|
by: yimma216 |
last post by:
Hi there.
I am looking for a way to generate a report from a web form and attached it to an email so that I could send it.
The form is retrieving data from a Microsoft SQL server and display...
|
by: cooksc |
last post by:
I have an Access database where I want to send a PDF file as an attachment. I have code that sends the basic email from Access through LotusNotes and it works well. What I would like help on is:...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: 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: 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,...
|
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: 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,...
| |