Stephen Byrom
asked on
Add attachments to email in Access
Hi,
I have some code from Ron De Bruin which I am trying to get to work with adding attachments. It breaks down at line 31 with the error "Type mismatch" yet I have declared the strings early on. see attached code;
As usual, any help is greatly appreciated.
Thanks
I have some code from Ron De Bruin which I am trying to get to work with adding attachments. It breaks down at line 31 with the error "Type mismatch" yet I have declared the strings early on. see attached code;
Option Compare Database
Option Explicit
Public Sub EmailProdRprt()
Dim OutApp As Object
Dim OutMail As Object
Dim ProdRprt1 As String
Dim ProdRprt2 As String
ProdRprt1 = "H:\All\Temp\ProdRprt.pdf"
ProdRprt2 = "H:\All\Temp\ProdRprt.xlsx"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Dim strMsg As String
Dim strTo As String
Dim strCopyTo As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strTo = "someone@somewhere.com;someoneelse@somewhereelse.com"
strMsg = "Testing" 'Forms!frmShiftWarning.txtMsg
strCopyTo = "copiedto@somewhere.com" 'Forms!frmShiftWarning.txtCopyTo
With OutMail
.To = strTo
.cc = strCopyTo
.BCC = ""
.Subject = "Production Reports"
.Body = strMsg
.Attachments.Add ProdRprt1, ProdRprt2
.Display
' .Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
As usual, any help is greatly appreciated.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER