2017-01-04 5 views
0

Outlook 범주의 도움을 받아 작업 (전자 메일)을 팀 구성원에게 할당하는 방법을 찾고 있지만이 방법을 사용하려면 수동으로 2000 개의 전자 메일이 있어야합니다. 거대한 작업도 나는 최신에 오래된 순으로 전체 사서함을 3) 할당을선택한 전자 메일에 범주로 작업 할당을위한 Outlook VBA

1) 아래가 선택된 이메일을 각 팀 구성원에 2) 할당을 3 이메일을 할당 달성하기 위해 노력하고 있지 않다 참석하다 이메일. 4) 아래 요구 사항에 따라 할당이 수행됩니다. 즉,

이메일을 10 개 선택하면 배포본은 이메일 1, 즉 1, 2, 3, 4, 5, 6, 즉 에이전트 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