Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: Uploading and Updating Draft Messages 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: 24 January 2017 at 5:52am | IP Logged Quote hmuscroft

Just when I think I've nearly finished implementing IMAP, something new keeps cropping up!

OK, so when a user chooses to SAVE A DRAFT of an email they're working on, I can upload it using "imap.UploadMessage(msg, draft_folder);"

However, if they then do some more editing of the email and click SAVE DRAFT again, I now need to UPDATE the existing email.

What is the best approach for this? Should I get the UID of the first draft upload, then DELETE it and RE-UPLOAD the new draft each time, or is there a way of updating the existing draft message on the imap server?

What would you recommend as best practice?

Many thanks (again!).
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 6:09am | IP Logged Quote Alex

You'll need to delete and upload a new draft each time. There is no UPDATE action of any kind in IMAP.

If the server supports UIDPLUS (and Hotmail does), you can get UID of uploaded message immediately during upload. This will give you a hint which message to delete next time when replacing an older draft.

Getting just the latest draft in the folder (instead of remembering UID of just uploaded message from UIDPLUs results) is not reliable. What if another draft is being edited simultaneously in a multi-user environment? However, if the server does not support UIDPLUS, getting the last UID is the only option. Just do it immediately after upload to minimize the risk that someone else also uploads a message between your upload and getting UID actions.

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 6:38am | IP Logged Quote hmuscroft

Yes that makes sense - thanks.

So I can get the "UidPlusResult" result of an imap.UploadMessage(...) and then I can check the .IsSupported to see if I can get the UID from that object.

But... if the server doesn't support UIDPLUS, then what method would you recommend to retrieve the last UID?
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 7:07am | IP Logged Quote Alex

Quote:

However, if the server does not support UIDPLUS, getting the last UID is the only option. Just do it immediately after upload to minimize the risk that someone else also uploads a message between your upload and getting UID actions.

DownloadEnvelopes(imp.MessageCount.ToString(), false, EnvelopeParts.Uid, 0)

You can go further and, for instance, with UID also download the message header and analyze Message-ID (or any other custom header of your choice which you can use to provide unique values to your drafts). If the draft's unique value is different from what you expect, it means someone else put it at the same time and you should repeat with a previous message, etc until you find the message you need. This pattern prevents possible race conditions even if UIDPLUS is not available.

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 7:12am | IP Logged Quote hmuscroft

Thanks Alex. I must congratulate you on your support which is first rate.
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 7:15am | IP Logged Quote Alex

Much appreciated :) Thanks!

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

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