Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone please help me with this script!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Can someone tell me what's wrong with this function!
I really don't see it.

I get an error on the line "Set oField = oRecip.AddressEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)"

Can anyone please help me!


This is the whole source of the script.

HELP!!HELP!!HELP!!HELP!!HELP!!HELP!!HELP!!HELP!!HELP!!

<SCRIPT RunAt=Server Language=VBScript>
Option Explicit
Dim iRuleCount
iRuleCount = 0
Dim Rules(0)


'Filling in rules array

Rules(0) = Array(4,&quot;email@address.com&quot;, 1,&quot;000000001A447390AA6611CD9BC800AA002FC45A030062625C45E457D311999600A0C9FC4F190000000714A60000&quot;)

Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E

'
' Global variables
'

Dim oMsg ' Message Object
Dim CDOSession ' Session Object
Dim oFolder ' Current Folder Object
Dim bDebug ' Debug turned off or on


bDebug = False



'
' DESCRIPTION: This event is fired when a message in the folder is created
'
Public Sub Folder_OnMessageCreated
Dim i ' Cycle variable

WriteDebugString &quot;Message created&quot;


Set CDOSession = EventDetails.Session ' get CDO session from

Set oMsg = CDOSession.GetMessage(EventDetails.MessageID,Null)
Set oFolder = CDOSession.GetFolder(EventDetails.FolderID, Null )

WriteDebugString &quot;Message object received&quot;


If Err.Number = 0 Then

For i=0 To iRuleCount

If Rules(i)(0) = 1 Then ' Sender name is

If oMsg.Sender.Name = Rules(i)(1) Then
PerformAction Rules(i)(2),Rules(i)(3)
End If

ElseIf Rules(i)(0) = 2 Then ' Receiver name is

If IsInRecipients(Rules(i)(1),1) Then
PerformAction Rules(i)(2),Rules(i)(3)
End If

ElseIf Rules(i)(0) = 3 Then ' Sender e-mail is

If oMsg.Sender.Address = Rules(i)(1) Then
PerformAction Rules(i)(2),Rules(i)(3)
End If

ElseIf Rules(i)(0) = 4 Then ' Receiver e-mail is
If IsInRecipients(Rules(i)(1),2) Then
PerformAction Rules(i)(2),Rules(i)(3)
End If

End If

Next

End If

Set oMsg = Nothing
Set oFolder = Nothing
Set CDOSession = Nothing

End Sub

'
' This is util procedure to perform specific action
'
Sub PerformAction(ActionType, FolderId)
If ActionType = 1 Then
oMsg.MoveTo(FolderId)
ElseIf ActionType = 2 Then
Dim oCopiedMessage
Set oCopiedMessage = oMsg.CopyTo(FolderId)
oCopiedMessage.Update
Set oCopiedMessage = Nothing
ElseIf ActionType = 3 Then
oMsg.Delete
End If
End Sub

'
' Checks if needed name is amoung recipients
'
' CheckParam - parameter to check
' 1 = Name
' 2 = Mail Address
'
Function IsInRecipients(Data, CheckParam)

Dim i
Dim oRecip
Dim oField
Dim v
Dim str

For i = 1 To oMsg.Recipients.Count
Set oRecip = oMsg.Recipients.Item(i)

If CheckParam = 1 Then
If LCase(oRecip.Name) = LCase(Data) Then
WriteDebugString &quot;Name matches&quot;
Set oRecip = Nothing
IsInRecipients = True
Exit Function
End If

ElseIf CheckParam = 2 Then

Set oField = oRecip.AddressEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)
' This line gives me an error
For Each v In oField.Value
If LCase(Right(v, Len(v)-InStr(v,&quot;:&quot;))) = LCase(Data) Then
WriteDebugString &quot;E-Mail address matches&quot;
Set oField = Nothing
Set oRecip = Nothing
IsInRecipients = True
Exit Function
End If

Next

Set oField = Nothing

End If

Set oRecip = Nothing
Next
IsInRecipients = False
End Function


'
' This outputs debug string
'
Sub WriteDebugString(str)

If bDebug Then
Script.Response = Script.Response & str & vbCrLf
End If

End Sub



' DESCRIPTION: This event is fired when a message in the folder is changed
Public Sub Message_OnChange
End Sub

' DESCRIPTION: This event is fired when a message is deleted from the folder
Public Sub Folder_OnMessageDeleted
End Sub

' DESCRIPTION: This event is fired when the timer on the folder expires
Public Sub Folder_OnTimer
End Sub

</SCRIPT>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top