Outlook 2013
Over a week reading similar codes and still cant pinpoint this, help greatly appreciated!
-Main problem it only renames the first attachment and i have no control over the other items in the email.
This code saves my attachment where I want, and renames it what I want. It works perfectly IF the email has only one attachment and no images in signature. If the email comes with one excel file and an image in signature, it renames the image what I intended to be the excel file name, and then leaves the excel file its original name.
Would be awesome if I can also dictate specific extensions for it to include in the download.
Public Sub saveAttachtoDisk_Vendor(itm As Outlook.MailItem) Dim objAtt As Outlook.Attachment Dim saveFolder As String Dim fso As Object Dim oldName Dim file As String Dim DateFormat As String Dim newName As String Dim enviro As String saveFolder = "S:\Test\" Set fso = CreateObject("Scripting.FileSystemObject") On Error Resume Next For Each objAtt In itm.Attachments file = saveFolder & objAtt.DisplayName objAtt.SaveAsFile file Set oldName = fso.GetFile(file) DateFormat = Format(oldName.DateLastModified, "yyyy-mm-dd ") newName = "Vendor.xls" oldName.Name = newName Set objAtt = Nothing Next Set fso = Nothing End Sub
I am toying with these codes from other scripts but cant seem to get them to work right, I am novice at the language.
And this.validExtString = ".doc .docx .xls .xlsx .msg .pdf .txt" ' <---- Update as needed validExtArray = Split(validExtString, " ")
If Right(atmt.FileName, 3) = "xls" Then FileName = "C:\Email Attachments\" & atmt.FileName atmt.SaveAsFile FileName i = i + 1 End If





 
			
			 
					
				 
                    
            
                 
            
            
         
					
					
					
						 Reply With Quote
  Reply With Quote 
			