Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: How to get "AllFlags" from MessageFlagSet Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 23 January 2017 at 12:54pm | IP Logged Quote hmuscroft

Hi - I'd like to get a list of all available 'message flags' on an IMAP server.

According to the documentation here :-
http://www.afterlogic.com/mailbee-net/docs/#MailBee.ImapMail.MessageFlagSet.html

... it should just be a case of iterating through :-
MailBee.ImapMail.MessageFlagSet.AllFlags

However, "MessageFlagSet" is not a static class and it also has no accessible constructor for me to instantiate it in order to get at the AllFlags property.

I'm probably missing something obvious, but please can you tell me how to achieve this?

Thanks!
Back to Top View hmuscroft's Profile Search for other posts by hmuscroft
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 23 January 2017 at 1:05pm | IP Logged Quote Alex

Perhaps, you're asking about Imap.PermanentFlags property. It gives you all message flags which can be set for a message on persistent basis.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 24 January 2017 at 12:40am | IP Logged Quote hmuscroft

I don't think that's what I'm after.

In fact, what I'm trying to accomplish is to flag a message as 'forwarded'.

I can see this has previously been discussed here :-
http://forum.afterlogic.com/forum_posts.asp?TID=4792&KW=forwarded

The answer you gave was :-

"While there's a standard Answered flag, Forwarded isn't among standard ones though it's widely used - and if you check string representation of message flags, you'll find that flag if it's supported by server and set for the message."

So what I'm trying to do is :-
(a) find out if a server supports a "Forwarded" flag; and
(b) if so how to set it?

Many thanks!
Back to Top View hmuscroft's Profile Search for other posts by hmuscroft
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 24 January 2017 at 12:47am | IP Logged Quote Alex

(a) It should be in Imap.PermanentFlags (Imap.PermanentFlags.AllFlags if you need array) after you selected a folder in which you want to flag your messages.

(b) I just checked, Hotmail does not support it.

0 select inbox
* 905 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 24 January 2017 at 1:17am | IP Logged Quote hmuscroft

Excellent - that's what I needed thanks.

This brings up another question. I read elsewhere that to flag a message as SPAM we can use this code :-

imp.SetMessageFlags(imp.MessageCount.ToString(), false, "$Spam", MessageFlagAction.Replace, false);

However, neither GMAIL nor HOTMAIL have a "Spam" flag. GMAIL has "Phishing" and "NotPhishing" flags.

Is "$Spam" a special keyword which intelligently works out how to flag a message as spam on any server, or should I be manually checking the flags on a server and picking an appropriate one (e.g. "$Phishing" for GMAIL)?
Back to Top View hmuscroft's Profile Search for other posts by hmuscroft
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 24 January 2017 at 1:35am | IP Logged Quote Alex

I'm afraid there is no common way of "spamming" a message. Although setting "$Spam" flag may work for some servers, you'll need to make this decision on per-server basis. I.e. you have some lists of hosts for which it's known from external sources that it can be done this way. It's not possible to analyze server's flags (like PermanentFlags above) to make this decision. The fact that the server provides $Spam flag does not yet mean it somehow processes and event "Someone set or unset this flag for a message". Maybe a particular server just sets the flag and that's all of it.

Another popular method is a server hook which triggers when a client moves a message to Spam folder. For instance, our own MailSuite Pro mails server works this way. If you move a message to Spam (or outside of Spam to "unspam" false positive occurrence), the spam filter learning action is executed.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 24 January 2017 at 4:28am | IP Logged Quote hmuscroft

OK - so the approach I am using for SPAM is as follows :-

[1] On connecting to the IMAP server, I ascertain which folder is the "SPAM" server (from the FOLDER FLAGS) and on SELECTING a folder, I check to see if there's an available message flag for 'SPAM' emails, as follows :-

Code:
SPAM_FLAG = "";
foreach (string f in m_imap.PermanentFlags.AllFlags)
  if (f.ToLower().StartsWith("$spam") || f.ToLower().StartsWith("$phish") || f.ToLower().StartsWith("$junk"))
    SPAM_FLAG = f;


[2] When the user clicks to mark an email as spam, I :-
(a) Flag the message (if 'SPAM_FLAG' is available)
(b) Move it to the SPAM folder

Please can you tell me if this approach seems reasonable or if I'm missing anything?

Many thanks again!
Back to Top View hmuscroft's Profile Search for other posts by hmuscroft
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 24 January 2017 at 4:30am | IP Logged Quote hmuscroft

*** EDIT ***
I can't edit my posts on this forum, so here's a correction to the above :-

[1] On connecting to the IMAP server, I ascertain which folder is the "SPAM" folder (from the FOLDER FLAGS)...
Back to Top View hmuscroft's Profile Search for other posts by hmuscroft
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 24 January 2017 at 4:50am | IP Logged Quote Alex

Yes, it seems reasonable but again, there is no guarantee the server will respect your efforts. Flags can be assigned, mail can be moved to spam but you can never tell if it triggered anything on the server or not.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
hmuscroft
Groupie
Groupie


Joined: 29 December 2009
Location: United Kingdom
Online Status: Offline
Posts: 72
Posted: 24 January 2017 at 4:56am | IP Logged Quote hmuscroft

That's fine - thanks Alex.
Back to Top View hmuscroft's Profile Search for other posts by hmuscroft
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide