the below action working just on the first mail in inbox how can i customized it to work on all mail item
-----------------------------------------------------------------------------
Public Class ThisAddIn
Private WithEvents mailItem As Outlook.MailItem
Private WithEvents items As Outlook.Items
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Startup
Dim ns As Outlook.NameSpace = Application.Session
Dim inbox As Outlook.MAPIFolder = ns.GetDefaultFolder( _
Outlook.OlDefaultFolders.olFolderInbox)
For Each o As Object In inbox.Items
If TypeOf o Is Outlook.MailItem Then
mailItem = o
Else
Exit For
End If
Next
AddHandler mailItem.CustomAction, AddressOf MailItem_CustomAction
Dim action As Outlook.Action = mailItem.Actions.Add()
action.Name = "My custom action"
action.ShowOn = Outlook.OlActionShowOn.olMenuAndToolbar
action.ReplyStyle = Outlook.OlActionReplyStyle.olLinkOriginalItem
'End If
End Sub
Private Sub MailItem_CustomAction(ByVal action As Object, _
ByVal response As Object, ByRef cancel As Boolean)
MessageBox.Show("Add mail")
mailItem.SaveAs("C:\Test.msg")
End Sub
End Class
---------------------------------------------------------------------