0

I have copied this script for separate attachment from mail to a folder.

       Public Sub ProcessarAnexo(Email As MailItem)
       Dim diretorioAnex As String
       diretorioAnex = "C:\Separados"

       Dim MailID As String
       Dim mailx As Outlook.MailItem

       MailID = Email.EntryID
       Set Mail = Application.Session.GetItemFromID(MailID)

       For Each anexo In mailx.Attachments
           If Rigth(anexo.FileName, 3) = "xml" Then
           MsgBox (anexo.FileName)
           anexo.SaveAsFile directorioanex & "\" & anexo.FileName
       End If
       Next
       Set mailx = Nothing

        End Sub

I try to execute the script from "execute rules now" , but it doesn't save anything in the folder "Separados".

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
alejandro carnero
  • 1,774
  • 7
  • 27
  • 43
  • 2
    Hi alejandro, In the interests of not only answering your question but also helping you to learn VBA, have you stepped through this code and found out on which line you get an error. Or have you put your mouse over the object name "mailx" to see if it is set to an object? – darbid Nov 23 '12 at 07:37

1 Answers1

0

The script works , Outlook 2010 have blocked macros and code , i have enabled OutLook to run VBA and Macros and all runs fine.

Thanks

alejandro carnero
  • 1,774
  • 7
  • 27
  • 43
  • 1
    I don't think so. The script as posted above could only work through applied syntax-correcting magic. But good you got things sorted out. – Paul-Jan Nov 23 '12 at 11:41