Outlook add-in: How to find localized name of the "Junk e-mail"folder

  • Thread starter Thread starter tnemec78@googlemail.com
  • Start date Start date
Status
Not open for further replies.
T

tnemec78@googlemail.com

Hi,

I am writing an C++COM add-in that will add improved spam filtering. I

have a toolbar with a "Mark as spam" button for this purpose. How do I

find out what is the name of the folder that acts as Junk e-mail

folder. I presume that the actual name and path to this folder can

differ based on the office localization and/or user language settings

and/or account settings ... It might as well be that no such folder

exists and it needs to be created (i.e. in pre-Office 2003 versions)

Please help.

Many thanks
 
Re: Outlook add-in: How to find localized name of the "Junk e-mail" folder

NameSpace.GetDefaultFolder(OlDefaultFolders.olFolderJunk) will work for any

Outlook version that has a Junk folder. That's language independent.

<tnemec78@googlemail.com> wrote in message

news:0a738f4c-6d45-442f-84f3-9b397c79e357@o20g2000vbh.googlegroups.com...
> Hi,
> I am writing an C++COM add-in that will add improved spam filtering. I
> have a toolbar with a "Mark as spam" button for this purpose. How do I
> find out what is the name of the folder that acts as Junk e-mail
> folder. I presume that the actual name and path to this folder can
> differ based on the office localization and/or user language settings
> and/or account settings ... It might as well be that no such folder
> exists and it needs to be created (i.e. in pre-Office 2003 versions)

> Please help.

> Many thanks
 
Firstly thank you very much for your quick reply, I really appreciate

it! I found out that this solution is almost there but not quite...

In my environment I have these Outlook folders:

\Personal Folders\

\Personal Folders\Deleted Items

\Personal Folders\Drafts

\Personal Folders\Inbox

\Personal Folders\Junk E-mail

\Personal Folders\Sent Items

> ...

\Archive Folders

\user@server.com\

\user@server.com\Inbox

\user@server.com\Inbox.Drafts

\user@server.com\Inbox.Sent

\user@server.com\Junk E-mail

> ...

The latter is my default data file or whatever it is called.

Now Session.GetDefaultFolder(olFolderJunk) points to \Private Folders

\Junk E-mail

but the REAL Junk E-mail folder (i.e. the one that Outlook uses for

this account) is \user@server.com\Junk E-mail

How do I find the path to that?
 
Re: Outlook add-in: How to find localized name of the "Junk e-mail" folder

If that's the case Outlook is totally confused. GetDefaultFolder() will

always and only retrieve folders from your default PST file or Exchange

mailbox. It cannot retrieve folders from other mail stores that aren't the

default.

NameSpace.Folders has all your loaded PST files. You can iterate that

collection and its subfolders, etc. to find any loaded folder. The pattern

looks like this:

NameSpace.Folders.Item(1).Folders.Item("Inbox").Folders.Item("myInboxSubfolder"),

etc.

<tnemec78@googlemail.com> wrote in message

news:c16da584-2596-4733-80da-0f862482e27c@r36g2000vbr.googlegroups.com...
> Firstly thank you very much for your quick reply, I really appreciate
> it! I found out that this solution is almost there but not quite...

> In my environment I have these Outlook folders:
> \Personal Folders\
> \Personal Folders\Deleted Items
> \Personal Folders\Drafts
> \Personal Folders\Inbox
> \Personal Folders\Junk E-mail
> \Personal Folders\Sent Items
> ...
> \Archive Folders
> \user@server.com\
> \user@server.com\Inbox
> \user@server.com\Inbox.Drafts
> \user@server.com\Inbox.Sent
> \user@server.com\Junk E-mail
> ...
> The latter is my default data file or whatever it is called.
> Now Session.GetDefaultFolder(olFolderJunk) points to \Private Folders
> \Junk E-mail
> but the REAL Junk E-mail folder (i.e. the one that Outlook uses for
> this account) is \user@server.com\Junk E-mail

> How do I find the path to that?
 
On 14 kvì, 20:35, " - " <kenslo...@mvps.org
wrote:
> If that's the case Outlook is totally confused. GetDefaultFolder() will
> always and only retrieve folders from your default PST file or Exchange
> mailbox. It cannot retrieve folders from other mail stores that aren't the
> default.

> NameSpace.Folders has all your loaded PST files. You can iterate that
> collection and its subfolders, etc. to find any loaded folder. The pattern
> looks like this:
> NameSpace.Folders.Item(1).Folders.Item("Inbox").Folders.Item("myInboxSubfolder"),
> etc.

> >

> http://www.slovaktech.com

> <tneme...@googlemail.com> wrote in message

> news:c16da584-2596-4733-80da-0f862482e27c@r36g2000vbr.googlegroups.com...
>
> > Firstly thank you very much for your quick reply, I really appreciate
> > it! I found out that this solution is almost there but not quite...

>
> > In my environment I have these Outlook folders:
> > \Personal Folders\
> > \Personal Folders\Deleted Items
> > \Personal Folders\Drafts
> > \Personal Folders\Inbox
> > \Personal Folders\Junk E-mail
> > \Personal Folders\Sent Items
> > ...
> > \Archive Folders
> > \u...@server.com\
> > \u...@server.com\Inbox
> > \u...@server.com\Inbox.Drafts
> > \u...@server.com\Inbox.Sent
> > \u...@server.com\Junk E-mail
> > ...
> > The latter is my default data file or whatever it is called.
> > Now Session.GetDefaultFolder(olFolderJunk) points to \Private Folders
> > \Junk E-mail
> > but the REAL Junk E-mail folder (i.e. the one that Outlook uses for
> > this account) is \u...@server.com\Junk E-mail

>
> > How do I find the path to that?


Thanks a lot. I have one more question regarding this:

Once a message is in a spam folder I guess there is no way to tell

where it came from? (in case I have implemented a more complex folder

logic instead of having just one Inbox folder)
 
Re: Outlook add-in: How to find localized name of the "Junk e-mail" folder

What do you mean by where it came from? Do you mean the sender? Nothing

changes with that.

If a spam comes in and gets directed to the Junk folder it obviously was

originally delivered to the Inbox, that's the only folder where the Junk

filter is active and the only place where incoming emails are delivered.

<tnemec78@googlemail.com> wrote in message

news:b4500543-e1ee-4206-9b9f-9ba239e27765@z19g2000vbz.googlegroups.com...

<snip
Thanks a lot. I have one more question regarding this:

Once a message is in a spam folder I guess there is no way to tell

where it came from? (in case I have implemented a more complex folder

logic instead of having just one Inbox folder)
 
On 15 kvì, 15:04, " - " <kenslo...@mvps.org
wrote:
> What do you mean by where it came from? Do you mean the sender? Nothing
> changes with that.

> If a spam comes in and gets directed to the Junk folder it obviously was
> originally delivered to the Inbox, that's the only folder where the Junk
> filter is active and the only place where incoming emails are delivered.

> >

> http://www.slovaktech.com

> <tneme...@googlemail.com> wrote in message

> news:b4500543-e1ee-4206-9b9f-9ba239e27765@z19g2000vbz.googlegroups.com...
> <snip
> Thanks a lot. I have one more question regarding this:

> Once a message is in a spam folder I guess there is no way to tell
> where it came from? (in case I have implemented a more complex folder
> logic instead of having just one Inbox folder)


What I meant is that I many people sort their incoming mail into

different folders based on some sort of a logic (say Inbox, Family,

Friends, Client1, Client2, ...) and when such message get marked as

spam by mistake then my "Not Spam" button handler can only move it

back into the Inbox (thus not placing it in the correct inbox context

folder (ie. Family)). Or am I getting it wrong and anything that lands

inside Inbox gets filtered based on the filtering rules anyway?
 
Re: Outlook add-in: How to find localized name of the "Junk e-mail" folder

Anything that gets added to Inbox will fire the junk filter and any rules

you have set up. If something is classified as spam you normally whitelist

it and/or the sender, then you move it where you want if the rules don't do

it, or you manually run the rules.

<tnemec78@googlemail.com> wrote in message

news:39be620e-a3bf-4158-a3c1-385eeff5060b@l28g2000vba.googlegroups.com...

<snip
What I meant is that I many people sort their incoming mail into

different folders based on some sort of a logic (say Inbox, Family,

Friends, Client1, Client2, ...) and when such message get marked as

spam by mistake then my "Not Spam" button handler can only move it

back into the Inbox (thus not placing it in the correct inbox context

folder (ie. Family)). Or am I getting it wrong and anything that lands

inside Inbox gets filtered based on the filtering rules anyway?
 
Will it be possible to call

Store.GetSpecialFolder(olFolderJunk) to retrieve a junk folder for

every store instead of retrieving the generic one via

Session.GetDefaultFolder(olFolderJunk) ? And in a similar way marking

stuff as not spam would then move the item to Store.GetSpecialFolder

(olFolderInbox)

Does it make any sense?
 
Re: Outlook add-in: How to find localized name of the "Junk e-mail" folder

You can locate the junk folders for any store, but how they work is just as

normal folders in Outlook unless it's the junk folder for the default store.

That's the only one that will do the junk mail processing as items come in.

If you open a PST file as a secondary store that junk folder won't be

active.

<tnemec78@googlemail.com> wrote in message

news:e374703c-6937-4aa7-92cd-4f93c2b3cee9@s21g2000vbb.googlegroups.com...
> Will it be possible to call

> Store.GetSpecialFolder(olFolderJunk) to retrieve a junk folder for
> every store instead of retrieving the generic one via
> Session.GetDefaultFolder(olFolderJunk) ? And in a similar way marking
> stuff as not spam would then move the item to Store.GetSpecialFolder
> (olFolderInbox)

> Does it make any sense?
 
OK I think I confused things a little bit. Now I am sure that I

finally found what I wanted to ask:

I found out that a store's Junk email can be identified as a 5th

element of the PR_ADDITIONAL_REN_ENTRYIDS IMAPIFolder property

Given a MailItem or a Folder instance how do I get that info? I assume

that I need to do something like this:

IUnknown *u;

folder->get_MAPIOBJECT(&u);

// will this give me the IMAPIFolder interface?

// How do I get the PR_ADDITIONAL_REN_ENTRYIDS property?

// How do I get the 5th element out of it?

// once I have it I can then do something like

namespace->GetFolderFromEntryID(entryID_received_from_steps_above);

Could you please shed some light on this? I did not find any source

code that does this. C# or C++ does not matter just as long as there

is something.

Many thanks
 
Re: Outlook add-in: How to find localized name of the "Junk e-mail" folder

I' not sure that's immutable and not dependent on the store provider, but

you get that PT_MV_BINARY property from the Inbox folder of a store using

the property tag 0x36D81102. Once you have that property it's just a array

of binary properties. So you get the 5th element of the array and then

convert that binary property into a hex string if you want.

<tnemec78@googlemail.com> wrote in message

news:982d303c-a43c-4ff4-a5fc-22b81ccbdf71@j12g2000vbl.googlegroups.com...
> OK I think I confused things a little bit. Now I am sure that I
> finally found what I wanted to ask:

> I found out that a store's Junk email can be identified as a 5th
> element of the PR_ADDITIONAL_REN_ENTRYIDS IMAPIFolder property
> Given a MailItem or a Folder instance how do I get that info? I assume
> that I need to do something like this:

> IUnknown *u;
> folder->get_MAPIOBJECT(&u);
> // will this give me the IMAPIFolder interface?
> // How do I get the PR_ADDITIONAL_REN_ENTRYIDS property?
> // How do I get the 5th element out of it?
> // once I have it I can then do something like
> namespace->GetFolderFromEntryID(entryID_received_from_steps_above);

> Could you please shed some light on this? I did not find any source
> code that does this. C# or C++ does not matter just as long as there
> is something.

> Many thanks
 
> I' not sure that's immutable and not dependent on the store provider, but
> you get that PT_MV_BINARY property from the Inbox folder of a store using
> the property tag 0x36D81102.


Can I find a source code anywhere that would show in detail how to do

this?

I don't know how to use property tag 0x36D81102 (I assume I do it

wrong)

void myfunction(CComPtr <Outlook::_MailItem> mi)

{

CComPtr <IDispatch> disp;

CComPtr <MAPIFolder> folder;

CComPtr <IUnknown> unk;

CComPtr <IMAPIFolder> ifolder;

SPropTagArray tags = {1, 0x36D81102/*PR_ADDITIONAL_REN_ENTRYIDS*/};

ULONG flags = 0, values;

LPSPropValue props;

mi->get_Parent(&disp);

disp->QueryInterface(__uuidof(MAPIFolder), (void **)&folder);

folder->get_MAPIOBJECT(&unk);

unk->QueryInterface(IID_IMAPIFolder, (void**)&ifolder);

ifolder->GetProps(&tags, flags, &values, &props);

> ..

at this point I think props should be filled with meaningfull data.

Debugger shows that props[0].Value.bin.cb == 6 but here the field props

[0].Value.bin.lb does not show anything similar to what OutlookSpy

shows :-(
 
Can I find a source code somewhere that shows how exatly do I get the

property with tag 0x36D81102 ???

I am probably doing something wrong. Here is what I do:

void myFunction(CComPtr <Outlook::_MailItem> mi)

{

CComPtr <IDispatch> disp;

CComPtr <MAPIFolder> folder;

CComPtr <IUnknown> unk;

CComPtr <IMAPIFolder> ifolder;

SPropTagArray tags = {1, 0x36D81102/*PR_ADDITIONAL_REN_ENTRYIDS*/};

ULONG flags = 0, values;

LPSPropValue props;

mi->get_Parent(&disp);

disp->QueryInterface(__uuidof(MAPIFolder), (void **)&folder);

folder->get_MAPIOBJECT(&unk);

unk->QueryInterface(IID_IMAPIFolder, (void**)&ifolder);

ifolder->GetProps(&tags, flags, &values, &props);

> ...

at this point props[0].Value.bin.cb == 6 according to the debugger but

props[0].Value.bin.lpb does not show anything similar to what

OutlookSpy reports :-(
 
Re: Outlook add-in: How to find localized name of the "Junk e-mail" folder

Unless Dmitry answers this you should post Extended MAPI questions in

microsoft.public.win32.programmer.messaging, where the MAPI people hang out.

Most of the examples for things like this I know of are for the Outlook or

Redemption object models.

<tnemec78@googlemail.com> wrote in message

news:85bfebba-d659-4190-b583-d487e9f90468@v4g2000vba.googlegroups.com...
> > I' not sure that's immutable and not dependent on the store provider, but
> > you get that PT_MV_BINARY property from the Inbox folder of a store using
> > the property tag 0x36D81102.


> Can I find a source code anywhere that would show in detail how to do
> this?
> I don't know how to use property tag 0x36D81102 (I assume I do it
> wrong)

> void myfunction(CComPtr <Outlook::_MailItem> mi)
> {
> CComPtr <IDispatch> disp;
> CComPtr <MAPIFolder> folder;
> CComPtr <IUnknown> unk;
> CComPtr <IMAPIFolder> ifolder;
> SPropTagArray tags = {1, 0x36D81102/*PR_ADDITIONAL_REN_ENTRYIDS*/};
> ULONG flags = 0, values;
> LPSPropValue props;

> mi->get_Parent(&disp);
> disp->QueryInterface(__uuidof(MAPIFolder), (void **)&folder);
> folder->get_MAPIOBJECT(&unk);
> unk->QueryInterface(IID_IMAPIFolder, (void**)&ifolder);
> ifolder->GetProps(&tags, flags, &values, &props);
> ...
> at this point I think props should be filled with meaningfull data.
> Debugger shows that props[0].Value.bin.cb == 6 but here the field props
> [0].Value.bin.lb does not show anything similar to what OutlookSpy
> shows :-(
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
G Add Map It button to Custom Contacts Form in Outlook Outlook VBA and Custom Forms 1
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
S Outlook 2019 Custom outlook Add-in using Visual Studio Outlook VBA and Custom Forms 0
F Want to add second email to Outlook for business use Using Outlook 4
M "Attachment Detacher for Outlook" add in, does it update the server copy of the email? Using Outlook 1
J GoDaddy migrated to Office365 - Outlook Wont Add Account Exchange Server Administration 21
F Outlook 2019 Outlook 2019 Add and Sync to New computer Comcast server Using Outlook 2
A iCloud Outlook Add In is causing Outlook 2021 to crash and got disabled Using Outlook 10
L did MS ever add way to text via Outlook Using Outlook 5
P How to add a column named categories when searching in Outlook Using Outlook 0
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
Witzker Outlook 2019 Pls. add a Prefix for OUTLOOK 2019 here Using Outlook 1
A "Get Add-Ins" - Which Version of Outlook to use Using Outlook 1
C Looking for feedback on new Outlook Add-in Using Outlook 0
G How to add a folder shortcut to outlook quick access toolbar? Using Outlook 6
G Add to Outlook Contacts - Point to non-default contacts folder Using Outlook 0
O Outlook tasks - Add text column with multiple lines Using Outlook 3
D Add date next to day name in Outlook Today calendar view Using Outlook 1
D iCloud Add-in not working in Outlook 2013 and Outlook 2016 After Windows Upgrade & iCloud Upgrade Using Outlook 2
L Tired of Outlook disabling Adobe PDF Creator add-in Using Outlook 1
Mark Foley Cannot enable add-in in outlook 2010 Using Outlook 0
iwshim outlook 2013 - I cannot see the "Manage Add-ins" Using Outlook 2
A Add to Outlook Contacts from email - default view Outlook VBA and Custom Forms 1
P Add a contact to the New Task in Outlook 2016 Using Outlook 2
O Outlook on Android - add BCC Using Outlook 2
J Execute Add-In Button from VBA Outlook 2016 Outlook VBA and Custom Forms 1
J vb to c# for Outlook add-in. Using Outlook 0
R Outlook add-in to create new contact from an email. Using Outlook 0
A add birthday to outlook contacts Using Outlook 1
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
C Need VBA code to automatically save message outside outlook and add date Outlook VBA and Custom Forms 1
R Add Exchange Account to existing POP3 Outlook 2007 Profile Using Outlook 0
O Outlook 2016 follow-up flags--how can I add dates? Using Outlook 1
J VB6 Add-in fails to load in Outlook 16 - message useless Outlook VBA and Custom Forms 4
Diane Poremsky Disable Outlook Add-ins (Apps) Using Outlook 0
Diane Poremsky The Best Outlook Store Add-ins Contest Using Outlook 0
Diane Poremsky Add to Outlook Contacts Bug (Fixed) Using Outlook 1
Diane Poremsky Add a Charm to Outlook Meetings Using Outlook 0
N Get the seconds with userproperties.add method VBA Outlook Outlook VBA and Custom Forms 4
D Outlook Add-on for Exchange Spam Management? Exchange Server Administration 2
O Add private notes or comments to Outlook meeting invite Using Outlook 4
J Outlook calendar...How to add an event or appointment without a border around it? Using Outlook 9
iwshim Can I add an Unsubscribe link to Outlook outgoing email? Something like this? Using Outlook 1
Mark Klaassen HOw to keep Outlook iCloud add-in enabled Using Outlook 4
Tech Checkers Make Outlook add Contact Card Address in Location Field based on Appointment Subject Name. Using Outlook 2
B No email accounts in outlook. Cannot add email Using Outlook 5
A iCloud add-on for Outlook: Reminder for new appointment is set to 'None' by default. How to change? Using Outlook 6
T Cannot successfully add gmail IMAP account to Outlook 2013. Using Outlook 1
D Preventing users to disable an Outlook Add-in Using Outlook.com accounts in Outlook 5

Similar threads

Back
Top