PDA

View Full Version : Saving attached e-mails in Outlook 2010



DominicGomar
02-09-2012, 08:52 AM
Hi,

Im trying to save all e-mail attachments from a particular sender to the c:\ automatically. I was using this code in outlook 2003 and seemed to work fine with a rule telling outlook to run the script. I've upgraded to Outlook 2010 and now this doesn't work, not even an error sign.


Sub GetManagerDataAttachment(MyMail As MailItem)

' On Error GoTo GetAttachments_err

Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer

i = 0
For Each Atmt In MyMail.Attachments
FileName = "C:\Fixing Files\" &Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
Next Atmt


' GetAttachments_exit:
' Set Atmt = Nothing
' Set Item = Nothing
' Set ns = Nothing

' Exit Sub
' GetAttachments_err:
' MsgBox "An unexpected error has occurred." _
' & vbCrLf & "Please note and report thefollowing information." _
' & vbCrLf & "Macro Name: GetAttachments"_
' & vbCrLf & "Error Number: " &Err.Number _
' & vbCrLf & "Error Description: " &Err.Description _
' , vbCritical, "Error!"
' Resume GetAttachments_exit

End Sub

Could anyone help me either changing the code above or suggesting one that works (have tried others found online but with no success)

Cheers