Salve!
Riporto il precedente post con le correzioni suggeritemi:
Salve!
Ho la necessità di far inoltrare in BCC ad un mio indirizzo istituzionale la posta che parte da 2 dei 3 account configurati nel computer del mio collega. Anche i 2 account del collega sono di tipo istituzionale, mentre il terzo è suo personale.
Ho trovato la seguente macro da installare in Outlook 2007 che Roberto Restelli ha suggerito a qualche altro utente:
Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next
' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address or resolvable
' to a name in the address book
strBcc = "arch...@prova.it"
'Controlla se il messaggio è inviato usando un account
' specifico, ad esempio 'pi...@pippo.it'
If Item.SendUsingAccount.SmtpAddress = "pr...@prova.it"
Then
'Aggiunge l'indirizzo in BCC:
Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you want still to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Cancel = True
End If
End If
End If
Set objRecip = Nothing
End Sub
Questa macro è stata da me modificata come segue:
Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
Dim IncludeBCC As Boolean
On Error Resume Next
' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address or resolvable
' to a name in the address book
strBcc = "paperino_mail"
IncludeBCC = False
'Controlla se il messaggio è inviato usando un account
' specifico, ad esempio '******@pippo.it'
If Item.SendUsingAccount.SmtpAddress = "topolino_mail" Then IncludeBCC = True
If Item.SendUsingAccount.SmtpAddress = "pluto_mail" Then IncludeBCC = True
If IncludeBCC Then
'Aggiunge l'indirizzo in BCC:
Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you want still to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Cancel = True
End If
End If
End If
Set objRecip = Nothing
End Sub
Dopo aver fatto qualche prova, ho scoperto che la macro funziona troppo bene! Infatti mi manda in BCC sia la posta che parte datopolino_mail, sia quella che parte da
pluto_mail ma anche quella che parte dall'account personale del mio colleganome.cognome_mail. E questo francamente è un po' troppo!
Cosa c'è che non va nella macro da me modificata?
Vorrei segnalare che come da suggerimento nella risposta ho provveduto a debuggure il codice e francamente non ho trovato nulla che non vada. Semplicemente, non funziona!
Ho infine cambiato la macro come segue:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next
' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address or resolvable
' to a name in the address book
strBcc = "paperino_mail"
'Controlla se il messaggio è inviato usando un account
' specifico, ad esempio '******@pippo.it'
If Item.SendUsingAccount.SmtpAddress = ("topolino_mail" Or "pluto_mail")
Then
'Aggiunge l'indirizzo in BCC:
Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you still want to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Cancel = True
End If
End If
End If
Set objRecip = Nothing
End Sub
Ed ho ottenuto lo stesso scarso risultato. Cioè ricevo le mail sia da topolino_mail, sia da pluto_mail ma
anche quella che parte dall'account personale del mio collega nome.cognome_mail.
In attesa, cordiali saluti.
Dodomail