jana
asked on
Script VBA to assign a value to a user-define column in Outlook 2007 Inbox
We want to create a Rules Wizard so when an email that we received is from example@domain.com, the user-defined column 'Type' in the Outlook 2007 Inbox will have the value "SUPPORT"
The Rules Wizard part we have it, we are looking for the VBA portion that will save the value to the column
The Rules Wizard part we have it, we are looking for the VBA portion that will save the value to the column
ASKER
We have worked with Rules Wizard and have created various, but not with script.
Hera is what we did: we placed your script within the MODULE in VBA but when creating the rules, it pops up a window 'Select Script' but is empty.
Please advice
Hera is what we did: we placed your script within the MODULE in VBA but when creating the rules, it pops up a window 'Select Script' but is empty.
Please advice
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tried it, and gave an error "Run-rime error '13'" (see pic)
ErrorRules.jpg
ErrorRules.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey buddy, dont say that! You guys in EE have been excellent with!!!
Will try & let you know
Thanx
Will try & let you know
Thanx
ASKER
Didn't work.
Also tried "Run this rule now on messages already in Inbox" and it didn't work.
Also tried "Run this rule now on messages already in Inbox" and it didn't work.
ASKER
We tested the Rules we created by changing it to assign a Category and it works. But with the script it doesn't. We place stop at "Sub SetTypeProperty(Item As MailItem)" to see it run line by line it does goes line by line but it doesn't fill the "Type" column.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, tested it. What I did was change the Type contents to "EE", then Alt-F11, CTRL-G and the "?..." and it does display the value I enter in the Type column. I can change the value and run your test steps and it displays the changed contents.
ASKER
I placed the Item.Save and still no show
>> What I did was change the Type contents to "EE",
How did you do that?
How did you do that?
ASKER
Ok What i did change the rule to sava SUPPORT In type column when the email received has TESTEE in the subject.
When sent, the rule didn't save SUPPORT in the type column; hence, Type is empty. So I went in the Type column and change he value to "EE" (this is done by hanging the view to permit changes directly from user in inbox). I can change the Type contents and user your yet steps and it does display the contents.
When sent, the rule didn't save SUPPORT in the type column; hence, Type is empty. So I went in the Type column and change he value to "EE" (this is done by hanging the view to permit changes directly from user in inbox). I can change the Type contents and user your yet steps and it does display the contents.
ASKER
I meant "when received my email, the rule didn't save SUPPORT in the type column"
So the value is changed successfully if you do it manually by any means, but not with the rule?
ASKER
The value is not changed. What i mean is that the test instruction:
"? Outlook.ActiveExplorer.Sel ection.Ite m(1).UserP roperties( "Type")"
Works after i manually change the "Type" contents. The Rules worked perfectly because I see via the "Stop" that the control does go thru the VBA lines. However, the value "SUPPORT" doesn't get saved in the received email.
I place Item.Save right before the END, is that correct?
"? Outlook.ActiveExplorer.Sel
Works after i manually change the "Type" contents. The Rules worked perfectly because I see via the "Stop" that the control does go thru the VBA lines. However, the value "SUPPORT" doesn't get saved in the received email.
I place Item.Save right before the END, is that correct?
Yes. Let me test again, with the complete workflow needed. Maybe I have overlooked something.
Works fine for me. I added the User Column Type to my view in OL2010, created a rule triggering the VBA code
Sub SetTypeProperty(Item As MailItem)
Item.UserProperties.Add("Type", olText) = "SUPPORT"
Item.Save
End Sub
and see the Type column filled with SUPPORT in my view. OL2007 or OL2010 do not differ in that regard (and OL2003 works the same, too).
ASKER
Strange ... it doesn't on mine& its ol2007. But will review on detail when back office.
Make sure you are really seeing the User Property, not any other field called "Type". It might be part of a customized form, and hence need to be addressed differently.
ASKER
It worked!! But I didn't nothin different. Let me check again.
ASKER
Thanx
Open in new window