我正在寻找一种方法,在我的团队成员的帮助下将工作(电子邮件)分配给我的团队成员,但是我必须手动这样做,因为我每天都有2000封电子邮件这是一个很重要的任务,我也参与其中我正在努力实现以下目标
1)为每个团队成员分配3封电子邮件 2)仅分配选定的电子邮件,而不是整个邮箱 3)按照从最旧到最新的电子邮件的顺序进行分配。 4)根据以下要求进行分配,即
如果选择10封电子邮件,分发应该看起来像电子邮件,即1,2,3代理1,电子邮件,即4,5,6代理2,电子邮件即7,8,9代理3和电子邮件,即10代理4和循环在这里停止。
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 :(得分: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