Hi,
Not sure if this is better suited here or the main forum, but here goes
I have the code below that is supposed to save an email attachment to a defined location on receipt in Outlook.
When the email is received I get error "424-Object required" but it is defined above??
Anyone tell me where I am going wrong please?
Thanks,
John
Not sure if this is better suited here or the main forum, but here goes
I have the code below that is supposed to save an email attachment to a defined location on receipt in Outlook.
Code:
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objAtt As Outlook.Attachment
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
Dim Msg As Outlook.MailItem
Dim saveFolder As String
If TypeName(item) = "MailItem" Then
Set Msg = item
' ******************
saveFolder = "C:\Automation"
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName '<-------Error Here
' ******************
Else
End If
ProgramExit:
Exit Sub
End Sub
When the email is received I get error "424-Object required" but it is defined above??
Anyone tell me where I am going wrong please?
Thanks,
John