Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Problem with UserPorperties in eMails

Geek News

Problem with UserPorperties in eMails
franz 8/7/2006 11:51:02 AM
Hello,

My Add-In adds a new Property to eMails. I use the typelibraries for
Outlook2000.
The Add in is developed in Delphi.

The userdefined field 'Printed' will set in the Inspector but not in the
INBOX-Folder.

In Inspector:

var AMailItem: MailItem;
AUserProperty: UserProperty;

AMailItem := FOutlookApp.ActiveInspector.CurrentItem as MailItem;
AProp := AMailItem.UserProperties.Find('Printed', EmptyParam);
if AProp = Nil then begin
AProp := AMailItem.UserProperties.Add('Printed', olText, True, EmptyParam);
AProp.Value := 'YES';
end
else begin
AProp.Value := 'YES';
end;
AMailItem.Save;

In the Inspector it works correct

In Folder (InBox):

AMailItem := FOutlookApp.ActiveExplorer.Selection.Item(1) as MailItem;
AProp := AMailItem.UserProperties.Find('Printed', EmptyParam);
if AProp = Nil then begin
AProp := AMailItem.UserProperties.Add('Printed', olText, True, EmptyParam);
AProp.Value := 'YES';
end
else begin
AProp.Value := 'YES';
end;
AMailItem.Save;

In the INBOX-Folder it not works. No Error - but the Field will not displayed.

Can someone help me?
franz


Re: Problem with UserPorperties in eMails
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 8/7/2006 8:54:19 PM
Did you actually step through your code? If UserProperties.Find cannot find
a property, it raises an error (DISP_E_UNKNOWNNAME), but you never trap it.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"franz" <franz[ at ]discussions.microsoft.com> wrote in message
news:C7EECA0B-2FE6-46D1-85B4-C2972EC04106[ at ]microsoft.com...
[Quoted Text]
> Hello,
>
> My Add-In adds a new Property to eMails. I use the typelibraries for
> Outlook2000.
> The Add in is developed in Delphi.
>
> The userdefined field 'Printed' will set in the Inspector but not in the
> INBOX-Folder.
>
> In Inspector:
>
> var AMailItem: MailItem;
> AUserProperty: UserProperty;
>
> AMailItem := FOutlookApp.ActiveInspector.CurrentItem as MailItem;
> AProp := AMailItem.UserProperties.Find('Printed', EmptyParam);
> if AProp = Nil then begin
> AProp := AMailItem.UserProperties.Add('Printed', olText, True,
> EmptyParam);
> AProp.Value := 'YES';
> end
> else begin
> AProp.Value := 'YES';
> end;
> AMailItem.Save;
>
> In the Inspector it works correct
>
> In Folder (InBox):
>
> AMailItem := FOutlookApp.ActiveExplorer.Selection.Item(1) as MailItem;
> AProp := AMailItem.UserProperties.Find('Printed', EmptyParam);
> if AProp = Nil then begin
> AProp := AMailItem.UserProperties.Add('Printed', olText, True,
> EmptyParam);
> AProp.Value := 'YES';
> end
> else begin
> AProp.Value := 'YES';
> end;
> AMailItem.Save;
>
> In the INBOX-Folder it not works. No Error - but the Field will not
> displayed.
>
> Can someone help me?
> franz
>
>


Re: Problem with UserPorperties in eMails
franz 8/8/2006 9:26:02 AM
Hi Dmitry

I tested it. That is not the problem.

When i cannot find the property, i add it to the 'AmailItem'.
After adding the property i can find it, but the property will not saved and
i cannot see it in the Folder.

I hope this helps you. Franz



"Dmitry Streblechenko" wrote:

[Quoted Text]
> Did you actually step through your code? If UserProperties.Find cannot find
> a property, it raises an error (DISP_E_UNKNOWNNAME), but you never trap it.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "franz" <franz[ at ]discussions.microsoft.com> wrote in message
> news:C7EECA0B-2FE6-46D1-85B4-C2972EC04106[ at ]microsoft.com...
> > Hello,
> >
> > My Add-In adds a new Property to eMails. I use the typelibraries for
> > Outlook2000.
> > The Add in is developed in Delphi.
> >
> > The userdefined field 'Printed' will set in the Inspector but not in the
> > INBOX-Folder.
> >
> > In Inspector:
> >
> > var AMailItem: MailItem;
> > AUserProperty: UserProperty;
> >
> > AMailItem := FOutlookApp.ActiveInspector.CurrentItem as MailItem;
> > AProp := AMailItem.UserProperties.Find('Printed', EmptyParam);
> > if AProp = Nil then begin
> > AProp := AMailItem.UserProperties.Add('Printed', olText, True,
> > EmptyParam);
> > AProp.Value := 'YES';
> > end
> > else begin
> > AProp.Value := 'YES';
> > end;
> > AMailItem.Save;
> >
> > In the Inspector it works correct
> >
> > In Folder (InBox):
> >
> > AMailItem := FOutlookApp.ActiveExplorer.Selection.Item(1) as MailItem;
> > AProp := AMailItem.UserProperties.Find('Printed', EmptyParam);
> > if AProp = Nil then begin
> > AProp := AMailItem.UserProperties.Add('Printed', olText, True,
> > EmptyParam);
> > AProp.Value := 'YES';
> > end
> > else begin
> > AProp.Value := 'YES';
> > end;
> > AMailItem.Save;
> >
> > In the INBOX-Folder it not works. No Error - but the Field will not
> > displayed.
> >
> > Can someone help me?
> > franz
> >
> >
>
>
>
Re: Problem with UserPorperties in eMails
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 8/8/2006 6:08:39 PM
I had no problem running the following VB script. Does it work for you?

set Msg = Application.ActiveExplorer.Selection.Item(1)
on error resume next
err.Clear
set prop = msg.Userproperties.Find("Printed")
if (prop is Nothing) or (err.Number <> 0) Then
set prop = msg.UserProperties.Add("Printed", olText, true)
End If
prop.Value = "YES"
msg.Save

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"franz" <franz[ at ]discussions.microsoft.com> wrote in message
news:D4907E56-606D-4E12-92EB-6CE1109D8E36[ at ]microsoft.com...
[Quoted Text]
> Hi Dmitry
>
> I tested it. That is not the problem.
>
> When i cannot find the property, i add it to the 'AmailItem'.
> After adding the property i can find it, but the property will not saved
> and
> i cannot see it in the Folder.
>
> I hope this helps you. Franz
>
>
>
> "Dmitry Streblechenko" wrote:
>
>> Did you actually step through your code? If UserProperties.Find cannot
>> find
>> a property, it raises an error (DISP_E_UNKNOWNNAME), but you never trap
>> it.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "franz" <franz[ at ]discussions.microsoft.com> wrote in message
>> news:C7EECA0B-2FE6-46D1-85B4-C2972EC04106[ at ]microsoft.com...
>> > Hello,
>> >
>> > My Add-In adds a new Property to eMails. I use the typelibraries for
>> > Outlook2000.
>> > The Add in is developed in Delphi.
>> >
>> > The userdefined field 'Printed' will set in the Inspector but not in
>> > the
>> > INBOX-Folder.
>> >
>> > In Inspector:
>> >
>> > var AMailItem: MailItem;
>> > AUserProperty: UserProperty;
>> >
>> > AMailItem := FOutlookApp.ActiveInspector.CurrentItem as MailItem;
>> > AProp := AMailItem.UserProperties.Find('Printed', EmptyParam);
>> > if AProp = Nil then begin
>> > AProp := AMailItem.UserProperties.Add('Printed', olText, True,
>> > EmptyParam);
>> > AProp.Value := 'YES';
>> > end
>> > else begin
>> > AProp.Value := 'YES';
>> > end;
>> > AMailItem.Save;
>> >
>> > In the Inspector it works correct
>> >
>> > In Folder (InBox):
>> >
>> > AMailItem := FOutlookApp.ActiveExplorer.Selection.Item(1) as MailItem;
>> > AProp := AMailItem.UserProperties.Find('Printed', EmptyParam);
>> > if AProp = Nil then begin
>> > AProp := AMailItem.UserProperties.Add('Printed', olText, True,
>> > EmptyParam);
>> > AProp.Value := 'YES';
>> > end
>> > else begin
>> > AProp.Value := 'YES';
>> > end;
>> > AMailItem.Save;
>> >
>> > In the INBOX-Folder it not works. No Error - but the Field will not
>> > displayed.
>> >
>> > Can someone help me?
>> > franz
>> >
>> >
>>
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net