Richard Cottrell
New Member
- Outlook version
- Outlook 2010 32 bit
- Email Account
- Exchange Server
Hi I am really new to VBA and have added a code that offers a list of subjects for all new emails. I would like to add code that counts how many of these subjects have been sent and seperatelty counts how may received
Eg:
Sent Received
Subject 1 =10 = 11
Subject 2 =31 = 6
Subject 3 = 4 = 0
Subject 4 = 6 = 14
Subject 5 = 19 = 7
The code I am using is
Public lstNo As Long
Public Sub ChangeSubject()
Dim objItem As Object
Dim oMail As Outlook.MailItem
Set objItem = GetCurrentItem()
Set oMail = Application.CreateItem(olMailItem)
oMail.Display
UserForm1.Show
' MsgBox "user chose " & lstNo & " from combo"
Select Case lstNo
Case -1
oMail.Subject = objItem.Subject
Case 0
oMail.Subject = "Chase 1"
Case 1
oMail.Subject = "Chase 2"
Case 2
oMail.Subject = "Complaint"
Case 3
oMail.Subject = "Technical Help"
Case 4
oMail.Subject = "Call Back"
End Select
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Set objApp = Nothing
End Function
Yours hopefully
Richard
Eg:
Sent Received
Subject 1 =10 = 11
Subject 2 =31 = 6
Subject 3 = 4 = 0
Subject 4 = 6 = 14
Subject 5 = 19 = 7
The code I am using is
Public lstNo As Long
Public Sub ChangeSubject()
Dim objItem As Object
Dim oMail As Outlook.MailItem
Set objItem = GetCurrentItem()
Set oMail = Application.CreateItem(olMailItem)
oMail.Display
UserForm1.Show
' MsgBox "user chose " & lstNo & " from combo"
Select Case lstNo
Case -1
oMail.Subject = objItem.Subject
Case 0
oMail.Subject = "Chase 1"
Case 1
oMail.Subject = "Chase 2"
Case 2
oMail.Subject = "Complaint"
Case 3
oMail.Subject = "Technical Help"
Case 4
oMail.Subject = "Call Back"
End Select
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Set objApp = Nothing
End Function
Yours hopefully
Richard