P
PHisaw
Hi,
Some time back, I entered a question asking if it was possible to be in
Access, click on a command button, store a created pdf document in a "temp"
file so that I might also be able to include, with code, the Access documents
that I need to send with this file. I had to pull away from this project,
but now am ready to tackle it again. Here is the code that was sent:
Dim strFile(10) ‘assuming you have 11 or less files in the directory that
you are wanting to attach.
Dim tmp as string, i as integer, intFileCount as integer, strPath as string
Dim strEmail as string, strCC as string, strBCC as string, strSubject as
string, strMsg as string
Sub EmailPDF()
strPath = "C:\PathToPDF's\â€
tmp = Dir(strPath & “*.pdfâ€)
While tmp <> ""
strFile(i) = tmp
i=i + 1
intFileCount = i
tmp = Dir()
Wend
Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)
strEmail = "(e-mail address removed)"
strCC = "(e-mail address removed)"
strBCC = "(e-mail address removed)"
strSubject = "My PDF"
strMsg = "Here's your PDF"
With outMsg
.Importance = olImportanceHigh
.To = strEmail
.CC = strCC
.BCC = strBCC
.Subject = strSubject
.Body = strMsg
For i = 1 to intFileCount -1
.Attachments.Add strPath & strFile(i)
Next i
.Display
.Send
End With
Set outApp = Nothing
Set outMsg = Nothing
End Sub
When I copied this code and replaced it with my file path, I received a
message "Compile Error - Invalid or unqualified reference" and the .pdf is
highlighted in the "tmp=" line of code.
Hopefully, I've made what I'm trying to do clear and if anyone can help with
this, it would be greatly appreciated.
Thanks in advance,
Pam
Some time back, I entered a question asking if it was possible to be in
Access, click on a command button, store a created pdf document in a "temp"
file so that I might also be able to include, with code, the Access documents
that I need to send with this file. I had to pull away from this project,
but now am ready to tackle it again. Here is the code that was sent:
Dim strFile(10) ‘assuming you have 11 or less files in the directory that
you are wanting to attach.
Dim tmp as string, i as integer, intFileCount as integer, strPath as string
Dim strEmail as string, strCC as string, strBCC as string, strSubject as
string, strMsg as string
Sub EmailPDF()
strPath = "C:\PathToPDF's\â€
tmp = Dir(strPath & “*.pdfâ€)
While tmp <> ""
strFile(i) = tmp
i=i + 1
intFileCount = i
tmp = Dir()
Wend
Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)
strEmail = "(e-mail address removed)"
strCC = "(e-mail address removed)"
strBCC = "(e-mail address removed)"
strSubject = "My PDF"
strMsg = "Here's your PDF"
With outMsg
.Importance = olImportanceHigh
.To = strEmail
.CC = strCC
.BCC = strBCC
.Subject = strSubject
.Body = strMsg
For i = 1 to intFileCount -1
.Attachments.Add strPath & strFile(i)
Next i
.Display
.Send
End With
Set outApp = Nothing
Set outMsg = Nothing
End Sub
When I copied this code and replaced it with my file path, I received a
message "Compile Error - Invalid or unqualified reference" and the .pdf is
highlighted in the "tmp=" line of code.
Hopefully, I've made what I'm trying to do clear and if anyone can help with
this, it would be greatly appreciated.
Thanks in advance,
Pam