hearthhrob4gals
Board Regular
- Joined
- Aug 20, 2014
- Messages
- 142
I need help in fixing the below script (save it as .vbs)
This code adds a randomizer (4 digit alphanumeric value) to each email received on all mailbox based on a time and date.
Currently its adding the randomizier based on the date mentioned in the script but its ignoring the time part. Need to fix the time part here
This code adds a randomizer (4 digit alphanumeric value) to each email received on all mailbox based on a time and date.
Currently its adding the randomizier based on the date mentioned in the script but its ignoring the time part. Need to fix the time part here
Code:
On Error Resume Next
Arr_MailBox = Array("Ideation")
Arr_Folder = Array("Inbox")
For x = 0 To 0
SharedMailBox = Arr_MailBox(x)
SharedMailBox_Folder = Arr_Folder(0)
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olFldr = olNS.Folders(SharedMailBox)
Set olFldr = olFldr.Folders(SharedMailBox_Folder)
Const VALID_TEXT = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
StartTime = "7/4/2018 4:02:01 PM"
EndTime = "7/4/2018 4:06:01 PM"
For Each olItem In olFldr.Items
MailRecDate = DateValue(olItem.ReceivedTime)
MailRecTime = TimeValue(olItem.ReceivedTime)
If MailRecDate & " " & MailRecTime <= DateValue(EndTime) & " " & TimeValueValue(EndTime) And MailRecDate & " " & MailRecTime >= DateValue(StartTime) & " " & TimeValueValue(StartTime) Then
MsgBox "Done"
For I = 0 To 4
Randomize
sNewSearchTag = sNewSearchTag & Mid(VALID_TEXT,Round(Rnd * Len(VALID_TEXT)),1)
Next
Set i = Null
Set vMailSubject = olItem.Subject
If olItem.Subject = "" Then
olItem.Subject = "Blank" & " " & sNewSearchTag
Else
olItem.Subject = Left(olItem.Subject, 80) & " " & sNewSearchTag
End If
olItem.Save
sNewSearchTag = Null
End If
Next
Next
On Error Goto 0