Hallo Allemaal,
Ik wil graag mijn mails die na 12 uur worden binnenkomen (Microsoft Outlook 2013), doorsturen naar één iemand in een lijst van 3 gebruikers welke random mails wordt verdeeld.
Ik heb het probleem dat hij de Dim randomPerson As New Random niet herkent.
Weet iemand of het mogelijk is en zo ja welke functie ik kan gebruiken ?
Met vriendelijke groet,
Robert
Ik wil graag mijn mails die na 12 uur worden binnenkomen (Microsoft Outlook 2013), doorsturen naar één iemand in een lijst van 3 gebruikers welke random mails wordt verdeeld.
Ik heb het probleem dat hij de Dim randomPerson As New Random niet herkent.
Code:
Private WithEvents objInboxItems As Items
Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
' A Items collections for folders we want to monitor
Set objInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
End Sub
Private Sub Application_Quit()
' disassociate global objects declared WithEvents
Set objInboxItems = Nothin
End Sub
Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
Dim lijst() As String
Dim words As String
words = "email-adres*email-adres*email-adres"
lijst = Split(words, "*")
Dim randomPerson As New Random
Dim olItems As Items, _
olItem As Object, _
olMailItem As MailItem, _
olAttachmentItem As Attachment, _
bolTimeMatch As Boolean
Set olItems = objInboxItems.Restrict("[Unread] = True")
For Each olItem In olItems
If olItem.Class = olMail Then
Set olMailItem = olItem
'Time for forwarding emails
bolTimeMatch = (Time >= #11:00:00 AM#) And (Time <= #11:59:59 PM#)
If bolTimeMatch Then
Dim objMail As Outlook.MailItem
Set objItem = olMailItem
Set objMail = objItem.Forward
'EXTERNAL E-MAIl adress
objMail.To = lijst(randomPerson.Next(0, lijst.Length))
objMail.Send
Set objItem = Nothing
Set objMail = Nothing
End If
End If
Next
End Sub
Function IsNothing(Obj)
If TypeName(Obj) = "Nothing" Then
IsNothing = True
Else
IsNothing = False
End If
End Function
Weet iemand of het mogelijk is en zo ja welke functie ik kan gebruiken ?
Met vriendelijke groet,
Robert