Accessing User Defined Fields in Outlook

江枫思渺然 提交于 2019-12-08 02:20:24

问题


So, I have a custom email form/message like below and I want to access the "Doc Title:" field value to insert it into the body of the email.

I currently have this code;

Function Item_Send()
    Item.Body = Item.Body + UserProperties.Find("TextBox1").Text
End Function

And I've tried multiple variations of this, such as Item.UserProperties.Find(...).Value, Find(...).Value by itself, UserProperties.Find("TextBox1", false).Text, etc.

Research;
CodeProject
MSDN Find Method Documentation
Microsoft Support - How to create an email message form
Microsoft Support - FAQ about custom outlook forms
Microsfot Support - Working with User Defined Fields

I just can't seem to find a solution.
The posted code returns Object requred: 'UserProperties.Find(...)'
If I add in false to the parameters I get; Object doesn't support this property of method: 'UserProperties.Find'
Find by itself gives me Type mismatch: 'Find'

And that's all the error messages I can get to come up. Any help would be greatly appreciated. (I'm using the Script Editor button to write the above code, not the Visual Basic button).


回答1:


Change the problematic line to

set prop = Item.UserProperties.Find("TextBox1")
if Not (prop Is Nothing) Then
  Item.Body = Item.Body + prop.Value
End If

Also make sure the property name is really "TextBox1", that sounds like a control name. Have a look at the item with OutlookSpy: click Item button, select the UserProperties property, click browse, go to the IEnumVariant tab, double click on the property.

You can also click the IMessage button to see the raw MAPI properties.



来源:https://stackoverflow.com/questions/16599607/accessing-user-defined-fields-in-outlook

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