Results 1 to 10 of 10

Thread: Exchange Server - Deleting Emails Issue - A Fix

  1. #1
    jjwdesign's Avatar
    jjwdesign is offline Sugar Community Member
    Join Date
    Dec 2006
    Location
    Orlando, FL
    Posts
    503

    Default Exchange Server - Deleting Emails Issue - A Fix

    Recently I started to look closer at the Exchange Server / IMAP email deletion problem. For many of us using MS Exchange with SugarCRM, the deletion process does not work correctly. I've taken a closer at this problem, and have come to the following conclusions and solutions.

    See the attached file.

    Main Files/Functions:
    Code:
    modules/InboundEmail/InboundEmail.php
    	 function deleteMessageOnMailServer
    	 function moveEmails
    The deleteMessageOnMailServer function controls the deletion (and/or expunges) of emails, but in an IMAP case it tries to move the emails (instead of just deleting them). I've noticed from several dozen tests that the moving is not working properly. The first problem is that the Sugar CRM programming attempts to move the message to the "Inbox.Trash" folder, which unfortunately does not exist. I tried to setup a "Trash" folder, but the Sugar CRM programming also has problems moving emails to any subfolders to the Inbox. It does seem to work when moving emails from the INBOX to other folders at the same level (only). I'm not sure if this is an Exchange issue, or something deeper.

    Regardless, MS Exchange likes to delete emails by placing them into the "Deleted Items" folder (not the INBOX.Trash folder). So, I changed the code in "modules/InboundEmail/InboundEmail.php" to use the "Deleted Items" folder. This accomplished the moving of the email from the INBOX to the Deleted Items folder. I also added an imap_expunge before the end of the deleteMessageOnMailServer function to ensure the deletion of any emails marked as deleted.

    Feel free to give these changes a try on your SugarCRM / MS Exchange Server combination and let me know if it works for you. I've commented most of the changes. Use at your own risk!
    Attached Files Attached Files
    Last edited by jjwdesign; 2008-04-11 at 07:41 PM.
    SugarForge Projects:
    JJWDesign Google Maps
    JJWDesign Tools and Reports

    Follow my blog postings at JJW Design.

  2. #2
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,597

    Default Re: Exchange Server - Deleting Emails Issue - A Fix

    Thank you for this detailed description.
    Now I understood that this issue can only be solved by some kind of language file.
    In Germany e.g. the exchange server names the "deleted items" folder to "Gelöschte Objekte".
    So Email will only work correct if there is a customizeable file for the Exchange folder names.

  3. #3
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: Exchange Server - Deleting Emails Issue - A Fix

    Thank you very much.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  4. #4
    jjwdesign's Avatar
    jjwdesign is offline Sugar Community Member
    Join Date
    Dec 2006
    Location
    Orlando, FL
    Posts
    503

    Default Re: Exchange Server - Deleting Emails Issue - A Fix

    No problem kuske. You've helped me out in the past. I like to return the favor when possible.

    Concerning the language file: I believe this needs to be programmed as an Inbound Email setting. Since each account may have a different Trash folder, this needs to be configurable at through the Mail Account settings screen. It might also be nice to be able to select/set the main Inbox to check mail.
    SugarForge Projects:
    JJWDesign Google Maps
    JJWDesign Tools and Reports

    Follow my blog postings at JJW Design.

  5. #5
    sgandhi is offline Sugar Team Member
    Join Date
    Aug 2007
    Posts
    217

    Default Re: Exchange Server - Deleting Emails Issue - A Fix

    Hi All,
    I am about to add the facility to choose the Trash folder on the UI when you create a Mail account. So for the deletion process we will move the emails to that particular folder.

    We had some issues in moving emails to subfolders of INBOX but its not because of the sugarcrm programming. In the forum post someone posetd a solution and it was the exchange server setting which was prventing that and after making that change it started working.

    Thanks for all your help.

    Thanks
    -Samir Gandhi

  6. #6
    jjwdesign's Avatar
    jjwdesign is offline Sugar Community Member
    Join Date
    Dec 2006
    Location
    Orlando, FL
    Posts
    503

    Default Re: Exchange Server - Deleting Emails Issue - A Fix

    Samir,

    Hopefully SugarCRM will consider supporting MS Exchange accounts with v5.1. I'm interested in that thread about the moving of emails within the Inbox. If you can find the message, please post it here.

    Thank you.
    SugarForge Projects:
    JJWDesign Google Maps
    JJWDesign Tools and Reports

    Follow my blog postings at JJW Design.

  7. #7
    andrewm is offline Sugar Community Member
    Join Date
    Jun 2005
    Posts
    47

    Default Re: Exchange Server - Deleting Emails Issue - A Fix

    Quote Originally Posted by jjwdesign
    Feel free to give these changes a try on your SugarCRM / MS Exchange Server combination and let me know if it works for you. I've commented most of the changes. Use at your own risk!
    Woohoo - very nice!!!

    I see you also catered for (though commented out) the deleted items folder not existing, in which case you do a direct delete of the message. This is guaranteed to be the case when using MS Public Folders, which don't have a deleted items folder (or rather not an accessible one).

    The only problem I'm seeing now is when you do an Empty Trash operation, or a direct delete operation, the message list is not updated. So currently you'd have to do a manual resync. Any idea what the fix for this would be?

  8. #8
    andrewm is offline Sugar Community Member
    Join Date
    Jun 2005
    Posts
    47

    Default Re: Exchange Server - Deleting Emails Issue - A Fix

    Quote Originally Posted by andrewm
    The only problem I'm seeing now is when you do an Empty Trash operation, or a direct delete operation, the message list is not updated. So currently you'd have to do a manual resync. Any idea what the fix for this would be?
    The fix for the delete operation is in deleteMessageOnMailServer
    Code:
            
            $GLOBALS['log']->debug("INBOUNDEMAIL: MoveEmail to Deleted Items FAILED - trying hard delete.");
            // JJW Added as delete; in-case the Trash Folder doesn't exist, we can just delete it.
            // Uncomment if you preferr hard deletes
            if(!imap_delete($this->conn, $uid, FT_UID)) {
                    $return = true;
                    // RAM update cache on fromFolder
                    $newOverviews = $this->getOverviewsFromCacheFile($uid, $this->mailbox, true);
                    $this->deleteCachedMessages($uid, $this->mailbox);
                    // RAM update cache on fromFolder
            }
            // JJW - End
    I can't as yet get the display to update on 'Empty Trash'

  9. #9
    andrewm is offline Sugar Community Member
    Join Date
    Jun 2005
    Posts
    47

    Default Re: Exchange Server - Deleting Emails Issue - A Fix

    I just upgraded to v5.2.0f and I see these fixes still haven't been applied

    Attached is a new inboundemail.php file with the required mods applied
    Attached Files Attached Files

  10. #10
    zlatan24 is offline Junior Member
    Join Date
    Feb 2011
    Posts
    1

    Default Re: Exchange Server - Deleting Emails Issue - A Fix

    Quote Originally Posted by jjwdesign View Post
    Samir,

    Hopefully SugarCRM will consider supporting MS Exchange accounts with v5.1. I'm interested in that thread about the moving of emails within the Inbox. If you can find the message, please post it here.

    Thank you.
    Only some applications surprised me. One of them quickly relieved me with similar trouble and would be helpful for any other problem to my way of thinking. It has quite good resources such as recovering ost file to new Exchange mailbox and resolving almost any problem connected with ms exchange server - restore pst to exchange 2003.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 22
    Last Post: 2006-05-22, 12:54 AM
  2. Migrare sugarcrm da un server ad un altro
    By danielevisiva in forum Italiano
    Replies: 2
    Last Post: 2006-01-19, 02:27 PM
  3. Tracking down a JSON server issue in 3.0.1b
    By MMorgan in forum General Discussion
    Replies: 4
    Last Post: 2005-11-09, 03:06 PM
  4. Json server still an issue...
    By PeterGutniak in forum Developer Help
    Replies: 0
    Last Post: 2005-05-24, 09:32 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •