Sorry about this. I posted this orginally on the Outlook forum and had no response. So thought this is perhaps a better forum.
I am trying to automatically save an attachment after it enters the inbox.I thought I would create a rule doing the following:-
Automatically run a script via a rule after an email enters the inbox and then move it to a dealt with folder.
I have added some VB script (found on the forum) to the VB editor. The is a public function I have created.
Then I have created a rule and run a script by selecting the public function.
But nothing happens.
The script is shown below: -
Public Sub Attachment_Save(objMailItem As MailItem)
Dim Outlook
Set Outlook = CreateObject("Outlook.Application")
FilePath = "c:\Downloads" 'attachment will be saved here
k = 1
j = Outlook.Session.Folders.Count
For i = 1 To Outlook.Session.Folders.Item(j).Folders.Count
Set Folder_Item = Outlook.Session.Folders.Item(j).Folders.Item(i)
If Folder_Item.Name = "Inbox" Then
For Each Mail_Item In Folder_Item.Items
IsTifFile = False
For Each Att_Item In Mail_Item.Attachments
FileName = FilePath & "\" & Att_Item
Att_Item.SaveAsFile FileName
k = k + 1
IsTifFile = True
Next
Next
End If
Next
End Sub
I not sure if I need all this script as I am just wanting to save the attachments coming into the inbox? Ideally with the file name based on the date/time of the computer to ensure they are all different.
Thanks in advance.
I am trying to automatically save an attachment after it enters the inbox.I thought I would create a rule doing the following:-
Automatically run a script via a rule after an email enters the inbox and then move it to a dealt with folder.
I have added some VB script (found on the forum) to the VB editor. The is a public function I have created.
Then I have created a rule and run a script by selecting the public function.
But nothing happens.
The script is shown below: -
Public Sub Attachment_Save(objMailItem As MailItem)
Dim Outlook
Set Outlook = CreateObject("Outlook.Application")
FilePath = "c:\Downloads" 'attachment will be saved here
k = 1
j = Outlook.Session.Folders.Count
For i = 1 To Outlook.Session.Folders.Item(j).Folders.Count
Set Folder_Item = Outlook.Session.Folders.Item(j).Folders.Item(i)
If Folder_Item.Name = "Inbox" Then
For Each Mail_Item In Folder_Item.Items
IsTifFile = False
For Each Att_Item In Mail_Item.Attachments
FileName = FilePath & "\" & Att_Item
Att_Item.SaveAsFile FileName
k = k + 1
IsTifFile = True
Next
Next
End If
Next
End Sub
I not sure if I need all this script as I am just wanting to save the attachments coming into the inbox? Ideally with the file name based on the date/time of the computer to ensure they are all different.
Thanks in advance.