Mail oppikken

Status
Niet open voor verdere reacties.

wintrip

Gebruiker
Lid geworden
7 dec 2004
Berichten
5
Hallo,

Ik ben op zoek naar een routine om mail automatisch als die aankomt in een van drie mailboxen, te kopieren naar een andere mailbox (dit is niet te doen met rules) Weet iemand iets?

Alvast bedankt,

Philip Wintrip
 
Is dat Outlook in een bedrijfsomgeving?

Zo ja, kun je een "journaling rule" op de exchange server configureren.
Setting up Journaling rules

Zonder een "third party" programma kan dat niet vanaf de outlook client gedaan worden.
 
Is het niet mogelijk om een binnenkomend mailtje met outlook vba automatisch te compieren naar de juiste box? Zit inderdaad in een bedrijfsomgeving, maar ik heb geen rechten op de exchange server.
 
Deze verplaatst alle ingekomen mails naar de map 'zaak'

Code:
Sub mail_verplaatsen()
  with createobject("outlook.application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    for j =1 to .items.count
      .Items(1).Move .parent.Folders(1).Folders("zaak")
    next
  End With
End Sub
 
Ik heb nu deze code gemaakt, maar ik blijf foutmeldingen krijgen, iemand een suggestie?

--------------------------------------------------------------------------------------------------------------------------------

Code:
Option Explicit
Public nextperson As Integer
Public nextadres As String
Rem Public mailperson As String
Public mailadresNL As String
Public mailadresBE As String
Public mailadresUK As String
Private Sub PlaatsInMap(mailperson As Variant)
        Dim tellertje As Integer
        Let mailadresNL = "Mailbox - Servicedesk SLNL"
        Let mailadresBE = "Mailbox - Servicedesk SLBE"
        Let mailadresUK = "Mailbox - Servicedesk SLUK"
        
        With CreateObject("outlook.application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
            Fand tellertje = 1 To 3
                If tellerje = 1 Then nextadres = "mailadresNL"
                If tellerje = 2 Then nextadres = "mailadresBE"
                If tellerje = 3 Then nextadres = "mailadresUK"
                Let nextadres = Outlook.MAPIFolder
                .Items(1).Move .Parent.Folders(1).Folders(mailperson)
            Next tellertje
        End With

End Sub
Private Sub cmdKlaar_Click()
        Rem Close Me
        End
End Sub

Private Sub cmdStop_Click()
        Let nextperson = 10
        Let lblRun.Visible = False
End Sub

Private Sub Label1_Click()

End Sub
Private Sub cmdStart_Click()
        Let lblRun.Visible = True
        Dim j As Integer
        Dim teller As Integer
        
        
    While nextperson < 10
               
           Let nextperson = 1
           
              Rem Nederland, Belgie, Engeland
              If nextperson = 1 And Damian_af.Value = False Then
                 PlaatsInMap ("Damian" And "Damian (UK)")
                 Else: If Damian_af.Value = True Then nextperson = 2
              End If
              If nextperson = 2 And Jantien_af.Value = False Then
                 PlaatsInMap ("Jantien (NL)" And "Jantien (BE)" And "Jantien (UK)")
                 Else: If Jantien_af.Value = True Then nextperson = 3
              End If
              If nextperson = 3 And Johan_af.Value = False Then
                 PlaatsInMap ("JBA")
                 Else: If Johan_af.Value = True Then nextperson = 4
              End If
              If nextperson = 4 And Lamine_af.Value = False Then
                 PlaatsInMap ("Lamine")
                 Else: If Lamine_af.Value = True Then nextperson = 5
              End If
              If nextperson = 5 And Marlo_af.Value = False Then
                 PlaatsInMap ("Marlo (NL)" And "Marlo (BE)" And "Marlo (UK)")
                 Else: If Marlo_af.Value = True Then nextperson = 6
              End If
              If nextperson = 6 And Mohammed_af.Value = False Then
                 PlaatsInMap ("Mohamed (NL)" And "Mohamed (BE)" And "Mohamed (UK)")
                 Else: If Mohammed_af.Value = True Then nextperson = 7
              End If
              If nextperson = 7 And Philip_af = False Then
                 PlaatsInMap ("Philip (NL)" And "Philip (BE)" And "Philip (UK)")
                 Else: If Philip_af.Value = True Then nextperson = 8
              End If
              If nextperson = 8 And Said_af.Value = False Then
                 PlaatsInMap ("Said (NL)" And "Said (BE)" And "Said (UK)")
                 Else: If Said_af.Value = True Then nextperson = 9
              End If
              If nextperson = 9 And Sven_af.Value = False Then
                 PlaatsInMap ("Sven")
                 Else: If Sven_af.Value = True Then nextperson = 1
              End If
              
              Let nextperson = nextperson + 1
           
        
        
    
    
    Wend
End Sub
 
Laatst bewerkt door een moderator:
Kijk eens bij F1 in de VBEditor.

Let wordt niet meer gebruikt, want overbodig
While... Wend is vervangen door het betere Do...Loop
Na next hoeft de teller van de lus niet vermeld te worden
Een lus bestaat uit for...next (en niet uit fand....next)
Rem is een doscommando; in VBA gebruik je daarvoor '
en kijk eens (F1) naar de methoden ven Me en de syntaxis die daarbij hoort.

En het kan ook zonder al die variabelen
 
Laatst bewerkt:
@wintrip Code graag tussen de codetags(#) s.v.p.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan