jimmyspinner
New member
- Local time
- Today, 10:25
- Joined
- May 17, 2007
- Messages
- 8
Hi there,
I've recently changed from Windows 2000 to a Windows XP build and although my version of MS Access is 2000 still I've had a problem with some code since the move.
The code originally attachs a database within an email and then sends it to a mailbox. It fails at the code in red.
Public Function sendEmail(strRecipient As String, strSubject As String, strFileName As String) As Boolean
On Error GoTo StartError
Dim strMessage As String
Dim objOutlook As Object
Dim objItem As Object
Dim intLoop As Integer
Dim strMyFiles As Variant
'Create a Microsoft Outlook object.
Set objOutlook = CreateObject("Outlook.Application")
'Create and open a new contact form for input.
Set objItem = objOutlook.CreateItem(0)
objItem.To = strRecipient
objItem.Subject = strSubject
strMyFiles = Split(strFileName, ",")
For intLoop = 0 To UBound(strMyFiles)
If strMyFiles(intLoop) <> "" Then
' only valid files
If Dir(strMyFiles(intLoop)) <> "" Then
' Attach file
objItem.Attachments.Add strMyFiles(intLoop)
End If
End If
Next
objItem.Send
'Quit Microsoft Outlook.
Set objOutlook = Nothing
Exit Function
StartError:
strMessage = MsgBox("Error: sendEMail/" & Err.Description, vbCritical)
Exit Function
End Function
I've made sure all the relevant references have been added but have had no success yet. Anything you can suggest would be of great help to me.
Kind Regards
Dave
aka jimmyspinner
I've recently changed from Windows 2000 to a Windows XP build and although my version of MS Access is 2000 still I've had a problem with some code since the move.
The code originally attachs a database within an email and then sends it to a mailbox. It fails at the code in red.
Public Function sendEmail(strRecipient As String, strSubject As String, strFileName As String) As Boolean
On Error GoTo StartError
Dim strMessage As String
Dim objOutlook As Object
Dim objItem As Object
Dim intLoop As Integer
Dim strMyFiles As Variant
'Create a Microsoft Outlook object.
Set objOutlook = CreateObject("Outlook.Application")
'Create and open a new contact form for input.
Set objItem = objOutlook.CreateItem(0)
objItem.To = strRecipient
objItem.Subject = strSubject
strMyFiles = Split(strFileName, ",")
For intLoop = 0 To UBound(strMyFiles)
If strMyFiles(intLoop) <> "" Then
' only valid files
If Dir(strMyFiles(intLoop)) <> "" Then
' Attach file
objItem.Attachments.Add strMyFiles(intLoop)
End If
End If
Next
objItem.Send
'Quit Microsoft Outlook.
Set objOutlook = Nothing
Exit Function
StartError:
strMessage = MsgBox("Error: sendEMail/" & Err.Description, vbCritical)
Exit Function
End Function
I've made sure all the relevant references have been added but have had no success yet. Anything you can suggest would be of great help to me.
Kind Regards
Dave
aka jimmyspinner