PC Review


Reply
Thread Tools Rate Thread

How do populate user defined fields with parsed string from an incoming email?

 
 
Ben Lawless
Guest
Posts: n/a
 
      26th Apr 2005
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!





*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      26th Apr 2005
Set is used only for objects, not for properties.

Try:
myUserProperty.Value = strDueDate

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


"Ben Lawless" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***


 
Reply With Quote
 
Ben Lawless
Guest
Posts: n/a
 
      28th Apr 2005

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



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      28th Apr 2005
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.

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


"Ben Lawless" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to design a custom form that use User defined fields defined on a particular folder (not the default inbox one) Lucas Campos Microsoft Outlook Form Programming 5 17th Aug 2007 05:03 PM
set user-defined email fields =?Utf-8?B?am9lbA==?= Microsoft Outlook Discussion 16 3rd Nov 2006 02:14 PM
Can I send email to many people using user-defined fields search? =?Utf-8?B?QW1hbmRh?= Microsoft Outlook Discussion 1 29th Aug 2006 08:44 PM
How do I populate a user defined email field I created in outlook? =?Utf-8?B?UmljaGFyZEM=?= Microsoft Outlook Discussion 0 1st Dec 2004 09:55 AM
Re: How to populate a defined number string with zeroes faisca_aem Microsoft Excel Misc 0 4th Nov 2004 10:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:24 PM.