Moderatori: Anthony47, Flash30005
Sub WorkAllFrom()
'http://www.pc-facile.com/forum/viewtopic.php?f=26&t=110711&p=649928#p649928
Dim daProc As MAPIFolder, Procd As MAPIFolder
Dim myNameSpace As NameSpace, myMex As Variant
Dim I As Long, BasePath As String, PS As String
Dim DayPath As String, J As Long, AttCnt As Long, mWAtt As Long, fCnt As Long, mTot As Long
Dim AName As String, myTim As Single, eDel As Single, flXls As Boolean, mRes As Long
Dim mSender, tAdr As String, fTipo As String
Dim bName As String, tSubj As String
'
Set myNameSpace = Application.GetNamespace("MAPI")
'
Set daProc = myNameSpace.Folders("pippo@aaa.com").Folders("Sales") '<<<Folder di origine
Set Procd = myNameSpace.Folders("pippo@aaa.com").Folders("Vendite") '<<< Folder di spostamento
BasePath = "C:\Prova\" '<<< La directory di salvataggio allegati
'
PS = "\"
DayPath = Format(Now, "yyyy-mm-dd")
If Right(BasePath, 1) <> PS Then BasePath = BasePath & PS
'
tAdr = "pippo@" '<<< Mittente
fTipo = ".pdf" '<<< Tipo di file
tSubj = "Vendite" '<<< Subject della mail
'
mTot = daProc.Items.Count
For J = daProc.Items.Count To 1 Step -1
Set myMex = daProc.Items(J)
flXls = False
If TypeOf myMex Is MailItem Then
mSender = myMex.SenderName
If InStr(1, mSender, tAdr, vbTextCompare) > 0 Then
myTim = Timer
AttCnt = myMex.Attachments.Count
If AttCnt > 0 Then
For I = 1 To AttCnt
AName = myMex.Attachments(I).DisplayName
If UCase(Right(AName, Len(fTipo))) = UCase(fTipo) And _
InStr(1, myMex.Subject, tSubj, vbTextCompare) > 0 Then
bName = DayPath & "_" & Format(Timer, "00000") & fTipo
'se file PDF, salva allegato:
fCnt = fCnt + 1
myMex.Attachments(I).SaveAsFile BasePath & bName
flXls = True
'eventuale attesa per >1 sec:
If (Timer - myTim) < 1 Then
eDel = (myTim + 1.5 - Timer)
myWait (eDel)
End If
End If
Next I
End If
If flXls Then mWAtt = mWAtt + 1
'Sposta messaggio:
myMex.Move Procd
End If
End If
Next J
mRes = daProc.Items.Count 'Itm residui (non mailItems)
MsgBox ("Completato... " & vbCrLf & "Messaggi esaminati: " & mTot _
& vbCrLf & "Mail (spostate) con allegati: " & mWAtt _
& vbCrLf & "Totale file salvati: " & fCnt _
& vbCrLf & "Messaggi esaminati ma non spostati: " & mRes)
End Sub
Sub myWait(ByVal myStab As Single)
Dim myStTiM As Single
'
myStTiM = Timer
Do 'wait myStab
DoEvents
If Timer > myStTiM + myStab Or Timer < myStTiM Then Exit Do
Loop
End Sub
Sub WorkAllFrom()
'http://www.pc-facile.com/forum/viewtopic.php?f=26&t=110711&p=649928#p649928
Dim daProc As MAPIFolder, Procd As MAPIFolder
Dim myNameSpace As Namespace, myMex As Variant
Dim I As Long, BasePath As String, PS As String
Dim DayPath As String, J As Long, AttCnt As Long, mWAtt As Long, fCnt As Long, mTot As Long
Dim AName As String, myTim As Single, eDel As Single, flXls As Boolean, mRes As Long
Dim mSender, tAdr As String, fTipo As String
Dim bName As String, tSubj As String
'
Set myNameSpace = Application.GetNamespace("MAPI")
'
Set daProc = myNameSpace.Folders("pippo@aaa.com").Folders("Sales") '<<<Folder di origine
Set Procd = myNameSpace.Folders("pippo@aaa.com").Folders("Vendite") '<<< Folder di spostamento
BasePath = "C:\Prova\" '<<< La directory di salvataggio allegati
'
PS = "\"
DayPath = Format(Now, "yyyy-mm-dd")
If Right(BasePath, 1) <> PS Then BasePath = BasePath & PS
'
tAdr = "pippo@" '<<< Mittente
fTipo = ".pdf" '<<< Tipo di file
tSubj = "Vendite" '<<< Subject della mail
'
mTot = daProc.Items.Count
Debug.Print "A", mTot
For J = daProc.Items.Count To 1 Step -1
Debug.Print ">>>"
Set myMex = daProc.Items(J)
flXls = False
Debug.Print "B", J
If TypeOf myMex Is MailItem Then
Debug.Print "C", J, myMex.SenderName
mSender = myMex.SenderName
If InStr(1, mSender, tAdr, vbTextCompare) > 0 Then
Debug.Print "D", J, "Pass"
myTim = Timer
AttCnt = myMex.Attachments.Count
Debug.Print "E", J, AttCnt
If AttCnt > 0 Then
For I = 1 To AttCnt
AName = myMex.Attachments(I).DisplayName
Debug.Print "E" & I, J, AName
If UCase(Right(AName, Len(fTipo))) = UCase(fTipo) And _
InStr(1, myMex.Subject, tSubj, vbTextCompare) > 0 Then
Debug.Print "EE" & I, J, "Pass", flXls
bName = DayPath & "_" & Format(Timer, "00000") & fTipo
'se file PDF, salva allegato:
fCnt = fCnt + 1
myMex.Attachments(I).SaveAsFile BasePath & bName
flXls = True
'eventuale attesa per >1 sec:
If (Timer - myTim) < 1 Then
eDel = (myTim + 1.5 - Timer)
myWait (eDel)
End If
End If
Next I
End If
If flXls Then mWAtt = mWAtt + 1
'Sposta messaggio:
myMex.Move Procd
End If
End If
Next J
mRes = daProc.Items.Count 'Itm residui (non mailItems)
MsgBox ("Completato... " & vbCrLf & "Messaggi esaminati: " & mTot _
& vbCrLf & "Mail (spostate) con allegati: " & mWAtt _
& vbCrLf & "Totale file salvati: " & fCnt _
& vbCrLf & "Messaggi esaminati ma non spostati: " & mRes)
End Sub
Sub myWait(ByVal myStab As Single)
Dim myStTiM As Single
'
myStTiM = Timer
Do 'wait myStab
DoEvents
If Timer > myStTiM + myStab Or Timer < myStTiM Then Exit Do
Loop
End Sub
>>>
B 1
C 1 ****** ********
A 1
>>>
B 1
C 1 ****** ********
Torna a Applicazioni Office Windows
problema ricezione notifiche outlook Autore: gianscooby |
Forum: Sistemi Operativi Windows Risposte: 2 |
Problemi di ricezione Mail su outlook Autore: danibi60 |
Forum: Applicazioni Office Windows Risposte: 2 |
Visitano il forum: Nessuno e 13 ospiti