Outlook 2007 Add-In - subject only updates after losing focus

别来无恙 提交于 2019-12-11 13:23:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!