2017-01-04 2 views
0

私はチームのメンバーにOutlookのカテゴリの助けを借りて仕事(メール)を割り当てる方法を探していますが、私はこれを毎日2000件のメールを考慮して手動で行う必要がありますのみ選択した電子メールに代入し、全体ではなく、メールボックス 3)割り当ては最も古い順) 2各チームメンバーに3通の電子メールを割り当てる)私はOutlook VBAでカテゴリを選択したメールでカテゴリに割り当てる

1以下を達成しようとしています、巨大なタスクがあまりにも出席され、最新に電子メール。 4)以下の要件に応じて割り当てが行われます。つまり、

メールが10個選択されている場合は、ディストリビューションは電子メール、つまりエージェント1に1,2,3、電子メール4,5,6はエージェント2に、電子メールエージェント3には7,8,9、メール4には10、ループはここで停止します。

Sub EmailCategories() 
Dim strCat As String 
Dim olmail As MailItem 
'If Item.Class = olmail Then 
'For i = 0 To 2 

For Each olmail In Outlook.Application.ActiveExplorer.Selection 
'olmail.Categories = "Agent - 1" 

Select Case i 
Case 0 
olmail.Categories = "Agent - 1" 
Case 1 
olmail.Categories = "Agent - 2" 
Case 2 
olmail.Categories = "Agent - 3" 
Case 3 
olmail.Categories = "Agent - 4" 
Case 4 
olmail.Categories = "Agent - 5" 
Case 5 
olmail.Categories = "Agent - 6" 
End Select 

'Item.Categories = mailMsg 
olmail.Item.Save 
Err.Clear 

Next 
'End If 
i = i + 3 
Debug.Print i 
If i = 5 Then 
i = 0 
End If 
End Sub 

答えて

0

私は最終的に以下のように共有するようにソリューションをクラックしました。ありがとうございました。

Sub category_assigment() 
Dim oOutlook As Object: Dim oExplorer As Object 
Dim i As Long: Set oOutlook = CreateObject("Outlook.Application") 
Dim objSelection As Outlook.Selection 
Dim Result As Integer 
Set objSelection = Application.ActiveExplorer.Selection 

Set oExplorer = oOutlook.ActiveExplorer: Dim oSelection As Object 
Set oSelection = oExplorer.Selection 
Dim oCategory As String 
'For i = 1 To oSelection.Count 
On Error Resume Next 
For i = oSelection.Count To 1 Step -1 
If oSelection.Item(i).Categories = "" Then 
For x = 0 To 15 
If x = 0 Then 
oCategory = "Agent 1" 
ElseIf x = 3 Then 
oCategory = "Agent 2" 
ElseIf x = 6 Then 
oCategory = "Agent 3" 
ElseIf x = 9 Then 
oCategory = "Agent 4" 
ElseIf x = 12 Then 
oCategory = "Agent 5" 
ElseIf x = 15 Then 
oCategory = "Agent 6" 
Else: GoTo Line01 
End If 
For y = 0 To 2 
If oSelection.Item(i - x - y).Categories = "" Then 
oSelection.Item(i - x - y).Categories = oCategory 
oSelection.Item(i - x - y).Save 
End If 
Next 
Line01: 
Next 
End If 
Next i 

Result = MsgBox("Total Emails Assigned : " & _ 
      objSelection.Count, vbInformation, "Selected Items") 

End Sub 
関連する問題