Hello,
I am trying to populate three user defined fields in my Inbox folder
with strings that I parse from an incoming email that meets a certain
criteria.
I am able to parse the three strings at the time the email comes in, but
I am not able to assign them to their respective columns in their Inbox
folder.
Here is my code so far:
Sub CustomMailMessageRule(Item As Outlook.MailItem)
Dim myOlApp As Outlook.Application
Dim strDueDate As String
Dim strPriority As String
Dim blnInitialResponse As Boolean
Dim strInitialResponse As String
Dim myUserProperty As Outlook.UserProperty
Dim myUserPropertyTwo As Outlook.UserProperty
Dim myUserPropertyThree As Outlook.UserProperty
On Error Resume Next
'Get Due Date from email body
strDueDate = ResponseMacro.ParseDueDate("Requested Completion
Date.+\s", Item.Body)
strDueDate = Trim(strDueDate)
If strDueDate = "" Then
strDueDate = "None"
End If
Set myUserProperty = Item.UserProperties.Add("Date Due", olText)
Set myUserProperty.Value = strDueDate
myUserProperty.AddToFolderFields
'Get Priority from email body
strPriority = ResponseMacro.ParsePriority("Priority.+\s", Item.Body)
strPriority = Trim(strPriority)
If strPriority = "" Then
strPriority = "N/A"
End If
Set myUserPropertyTwo = Item.UserProperties.Add("Priority Lvl",
olText)
Set myUserPropertyTwo.Value = strPriority
myUserPropertyTwo.AddToFolderFields
'Set Inital Response sent to True
blnInitalResponse = False
strInitialResponse = CStr(blnInitalResponse)
Set myUserPropertyThree = Item.UserProperties.Add("Initial Sent",
olText)
Set myUserPropertyThree.Value = strInitialResponse
myUserPropertyThree.AddToFolderFields
myOlApp.Close olSave
MsgBox "Running script" & " _ " & strDueDate & " _ " & strPriority &
" _ " & strInitialResponse
End Sub
The Msg Box is just used to verify that the strings are being captured
and that the values are correct. Any help would be appreciated.
Thanks!
Ken Slovak - [MVP - Outlook] - 26 Apr 2005 14:31 GMT
Set is used only for objects, not for properties.
Try:
myUserProperty.Value = strDueDate

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> Hello,
>
[quoted text clipped - 63 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***
Ben Lawless - 28 Apr 2005 00:58 GMT
So, here is the code now:
Sub CustomMailMessageRule(Item As Outlook.MailItem)
'notice that this is being run from a rule script
Dim myOlApp As Outlook.Application
Dim strDueDate As String
Dim myUserProperty As Outlook.UserProperty
On Error Resume Next
'Get Due Date from email body. Calls an external function
strDueDate = ResponseMacro.ParseDueDate("Requested Completion
Date.+\s", Item.Body)
strDueDate = Trim(strDueDate)
If strDueDate = "" Then
strDueDate = "None"
End If
myUserProperty = Item.UserProperties.Add("Date Due", olText)
myUserProperty.Value = strDueDate
myUserProperty.AddToFolderFields
myOlApp.Close
MsgBox "Running script" & " " & strDueDate ' & " _ " & strPriority &
" _ " & strInitialResponse
End Sub
It is still not populating the fields that are being created in my
inbox.
Is there something that I am missing? Most likely :)
Any help appreciated.
Thanks,
Ben
Ken Slovak - [MVP - Outlook] - 28 Apr 2005 15:06 GMT
Please post parts of the preceding thread in your messages, that interface
you are using doesn't do that and it makes it very hard to follow things.
Set myUserProperty = Item.UserProperties.Add("Date Due", olText)
You use Set to instantiate objects. You don't use set when you set a value
for the objects that you've instantiated. I'd suggest looking over the form
code samples at www.outlookcode.com to get a handle on the basic syntax you
need to use for Outlook coding.

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> So, here is the code now:
>
[quoted text clipped - 36 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***