Answer the question
In order to leave comments, you need to log in
How to make comments to letters in Outlook through a form created in VBA?
In fact, how to create a comment and attach it to each letter by creating a custom field is described in detail for example here http://evo.engineering/quick-add-comments...
But, reading this comment is very difficult if it is long enough.
There is an idea to make a macro with an embedded form that will read the comment from the user field "Comment" and show it in the TextBox.
Those. By writing the code under the spoiler, when the macro is activated, we can easily display the contents of the user field "Comment" from the current selected message in the TextBox UserForm:
Private Sub UserForm_Activate()
Dim myItem As Object
'Инициализируем текущее выбранное сообщение
Set myItem = Outlook.Application.ActiveExplorer.Selection(1)
On Error Resume Next
TextBox1.Value = myItem.UserProperties.Add("Комментарий", olText, True).Value
End Sub
Answer the question
In order to leave comments, you need to log in
Found the answer:
Add a procedure tied to the Application_ItemLoad event to the VBA Project section "Microsoft Outlook Objects / ThisOutlookSession".
This assumes that the custom "Comment" field has already been manually added to the message fields.
Do not forget to catch errors that occur when starting Outlook, which occur due to the fact that the script is already running, but ActiveExplorer has not yet started and there is no selected message yet.
The code works only when the text of the letter has loaded for viewing in the compact view (and this happens every time you select the next letter), so the system and the processor do not load.
Private Sub Application_ItemLoad(ByVal Item As Object)
Dim myItem As Object
On Error Resume Next
Set myItem = Outlook.Application.ActiveExplorer.Selection(1)
If UserForm1.Visible Then
UserForm1.TextBox1.Value = myItem.UserProperties.Add("Комментарий", olText, True).Value
End If
Err.Clear
End Sub
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question