Salve, ci provo con un nuova domanda.
Macro sempre passata da sede estera,senza grandi spiegazioni.
Premetto non ho mai lavorato su macro excel che si collegano ad outlook quindi non conosco le variabili , sto' cercando di documentarmi ma non trovo granche'.
Da che ne so' la macro dovrebbe estrarre da alcune mail dell'utente "pippo paperino"
gli allegati e le informazioni e salvarli in un file excel.
qualche buon anima saprebbe darmi lumi sulle righe del codice che ho commnetato sotto (in italiano) per capire se sto' ragionando giusto o se sono proprio fuori strada?
Ho immesso il nome del mio utente (pippo paperino) ma pare che la macro esca sempre alla riga commentata sotto.
codice:Sub Get_utente_azienda_inbox_folder() Dim myNameSpace As Outlook.Namespace Dim myInspector As Outlook.Inspector Dim myOlApp As Outlook.Application Dim myFolder As Outlook.MAPIFolder Dim myFolders As Outlook.Folders Dim myOlItem As Object Dim MyItem As Object Dim myattachment As Outlook.Attachment Dim myOlattachments As Outlook.Attachments Dim myattachments As Outlook.Attachments Dim myOlattachment As Outlook.Attachment Dim myOlInspector As Outlook.Inspector Dim myInbox As Outlook.MAPIFolder Dim myDestFolder As Outlook.MAPIFolder Dim mySourceFolder As Outlook.MAPIFolder Dim myRecipient As Outlook.Recipient Dim lgIndex As Long Dim lgIndex1 As Long Set myOlApp = CreateObject("Outlook.Application") Set myNameSpace = myOlApp.GetNamespace("MAPI") Set myInspector = myOlApp.ActiveInspector Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox) 'qui dovrebbe collegarsi alla casella di posta del mio utente pippo paperino,giusto? Set myRecipient = myNameSpace.CreateRecipient("pippo paperino") 'cosa fa' la riga sotto? myRecipient.Resolve ' #### dopo questa riga la mia macro va direttamente alla fine perche?? ### If myRecipient.Resolved Then Set myFolder = myNameSpace.GetSharedDefaultFolder(myRecipient, olFolderInbox) Set myDestFolder = myNameSpace.GetSharedDefaultFolder(myRecipient, olFolderInbox) myFolder.DisplaymyFolder.Display Set myDestFolder = myFolder.Folders("azienda-Archive") Set mySourceFolder = myFolder.Folders("azienda") Debug.Print mySourceFolder.Name 'For every entry ( email ) in the sourcefolder Inbox ==> pippo paperino\azienda For lgIndex = mySourceFolder.Items.Count To 1 Step -1 Set myOlItem = mySourceFolder.Items(lgIndex) myOlItem.Display Set myInspector = myOlApp.ActiveInspector Set MyItem = myInspector.CurrentItem Debug.Print MyItem ' check for the defined email with attachment on email-subject If InStr(1, MyItem.Subject, "Comunicazione modifica") > 0 Then Set myattachments = myInspector.CurrentItem.Attachments Debug.Print myattachments.Count If myattachments.Count > 0 Then ' For every attachment in a email For lgIndex1 = 1 To myattachments.Count Debug.Print myattachments.Item(lgIndex1).DisplayName Set myattachment = myattachments.Item(lgIndex1) ' Save attachment to filesystem myattachment.SaveAsFile ("C:\dati\mail\" & myattachment.DisplayName) Next lgIndex1 End If ' Close email MyItem.Close olSave ' Move email to destination folder ==> pippo paperino\azienda-Archive MyItem.Move myDestFolder Else If InStr(1, MyItem.Subject, "Lancio ") > 0 Then MyItem.Close olSave MyItem.Move myDestFolder Else MyItem.Close olSave End If End If Set MyItem = Nothing Next lgIndex MsgBox "The folder 'azienda' was worked !" End If End Sub

Rispondi quotando