简体   繁体   中英

Accessing User Defined Fields in Outlook

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).

在此处输入图像描述

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.

You never check that UserProperties.Find returns null. 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 (I am its author): 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM