问题
I'm making a plugin for outlook 2007 and have only just started. I added a button that displays a messagebox showing the body and subject of the email being composed, and it seems as though the subject only updates once that field loses focus, while body updates immediately. If a user were to fill out the body, then the subject and click my button while the focus was still on the subject field then it would gather nothing as the subject content.
I'm gathering the data simply as:
If Not (mailItem Is Nothing) Then
If mailItem.EntryID Is Nothing Then
body = mailItem.Body
subject = mailItem.Subject
MessageBox.Show("Subject is: " + subject + "| And body is: " + body)
End If
End If
Does anyone know a workaround for this? I looked into changing the focus to the body and back to the subject if the focus was originally there but I'm not very familiar at all with outlook and some quick googling suggests that changing focus isn't possible in outlook.
回答1:
Try to save mailItem. Smth like mailItem.Save()
If you actually do not want to, then catch mailitem.write event and set boolean cancel, which passed as a reference, to true. Therefore the item will not be saved but subject should be updated.
来源:https://stackoverflow.com/questions/19034817/outlook-2007-add-in-subject-only-updates-after-losing-focus