Hello!
How to check in Vba macro event in Outlook ?
I need check if it selected or not message's in inbox folder. And if yes change some fields in it.
Thanx!
Hello!
How to check in Vba macro event in Outlook ?
I need check if it selected or not message's in inbox folder. And if yes change some fields in it.
Thanx!
Not sure what you mean exactly here, but the easiest way to check messages in the Inbox is to use a Rule. If you need to run some code once you have used the rule to select a message, write a macro in the VBEditor that is passed a reference to a mail message e.g: [VBA]Sub Test(Item As Outlook.MailItem)
'do some stuff
End Sub
[/VBA] then choose "run a script" in your rule action and click the link to select your macro
K :-)
So, it's example from outlook help: I just try to add extra line to change a user difined field in all recieved letters that I selected. But actualy it change only first selected letter.
How just change field for all letters ?
[vba]Sub newtest()
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim MsgTxt As String
MsgTxt = "You have selected items from" & Chr(13) & Chr(13)
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For x = 1 To myOlSel.Count
MsgTxt = MsgTxt & myOlSel.Item(x).SenderName & Chr(13)
'extra line
myOlSel.Item(x).UserProperties.Item("My storage Number") = "111"
Next x
MsgBox MsgTxt
End Sub[/vba]
Thanx
very strange... I don't understand why it applies to the first one only. I made it work by saving each mail item afterwards. Also, you should "Add" the userproperty[VBA]'declare a variable fro mailitems
Dim myItem As MailItem
'loop through all the items in the selection
For Each myItem In myOlSel
myItem.UserProperties.Add("My storage Number", olText) = "111"
myItem.Save 'save it!
Next[/VBA]
K :-)
Thanx Killian! - it's working!
Hi!
The same question, just another event
"Ssomebody change data in UserDefinedField in letter"
How to catch it ?
And maybe it present some library for event in outlook ?