Results 1 to 8 of 8

Thread: Automatically Import email into sugarcrm

  1. #1
    mutuku is offline Member
    Join Date
    Oct 2008
    Posts
    5

    Default Automatically Import email into sugarcrm

    Hello Forum,

    I would like to configure email to be imported automatically once it is received in sugar crm. How do I do this. I want it automated so that users do not have to click on "import to sugarcrm"

    I am using sugarcrm 5.1 open source running on centos 5.0

    James Mutuku Ndeti
    Last edited by mutuku; 2008-10-29 at 04:50 PM. Reason: more information

  2. #2
    clint's Avatar
    clint is offline Sugar Team Member | Forums Lead Moderator
    Join Date
    Aug 2004
    Location
    Silicon Valley
    Posts
    2,120

    Default Re: Automatically Import email into sugarcrm

    Set up the email account you want to monitor as a group mail account.

    See this blog post for more details.
    Sugar Developer Zone - developer resources | Sugar University - user and admin training
    Sugar Docs - user and admin documentation |
    Sugar Bug Tracker - Enter or view bugs
    SugarForge- open source modules, themes, lang packs | SugarExchange - commercial extensions

    Clint Oram
    Chief Technology Officer and Co-founder
    SugarCRM

  3. #3
    mutuku is offline Member
    Join Date
    Oct 2008
    Posts
    5

    Default Re: Automatically Import email into sugarcrm

    Thanks clint for the response.

    I have a few iisues:-

    -I wanted to setup "automated import" for individual users. Is there a way I can create a group for each user..and allow only that user to view the folder for that group? Is "automatic import" possilbe for individual users?
    -I have setup a group account and configured cron. On admin->Scheduler, the "check inbound mailboses" says it is in progress. But I cannot see any mail in the group email box.In "sugarcrm.log" i an getting the errors below

    Thu Oct 30 15:12:03 2008 [4730][1][FATAL] Error fetching relationship from cache schedulers_created_by
    Thu Oct 30 15:12:40 2008 [4729][1][FATAL] Error fetching relationship from cache schedulers_created_by
    Thu Oct 30 15:13:56 2008 [4729][1][FATAL] Error fetching relationship from cache schedulers_created_by
    Thu Oct 30 15:14:02 2008 [4736][1][FATAL] Error fetching relationship from cache schedulers_created_by
    Thu Oct 30 15:14:58 2008 [4796][1][FATAL] If you see a whole string of these, there is a chance someone is attacking your system.
    Thu Oct 30 15:20:12 2008 [4914][1][FATAL] If you see a whole string of these, there is a chance someone is attacking your system.
    Thu Oct 30 15:20:49 2008 [5079][1][FATAL] If you see a whole string of these, there is a chance someone is attacking your system.
    Thu Oct 30 15:29:03 2008 [8513][1][FATAL] If you see a whole string of these, there is a chance someone is attacking your system.
    Thu Oct 30 15:35:26 2008 [4800][1][FATAL] MySQL error 2006: MySQL server has gone away
    Thu Oct 30 16:12:43 2008 [8034][1][FATAL] Error fetching relationship from cache schedulers_created_by
    Thu Oct 30 16:22:31 2008 [8035][1][FATAL] Error fetching relationship from cache schedulers_created_by
    Thu Oct 30 16:40:00 2008 [8036][1][FATAL] Error fetching relationship from cache schedulers_created_by
    Thu Oct 30 16:45:18 2008 [8039][1][FATAL] Error fetching relationship from cache schedulers_created_by


    Even after Rebuilding Relationships, I am getting the same error and the mailbox is still empty.

    What could be the issue? Please help

  4. #4
    mutuku is offline Member
    Join Date
    Oct 2008
    Posts
    5

    Default Re: Automatically Import email into sugarcrm

    Hello,

    I have searched the forum for a solution to this...but no success. Any one with a solution/workaround for this?

    James

  5. #5
    kirvent4 is offline Junior Member
    Join Date
    Oct 2009
    Posts
    2

    Default Re: Automatically Import email into sugarcrm

    I'm also looking for a solution to a similar problem/desired outcome. Thanks!

  6. #6
    helpdeskite is offline Member
    Join Date
    Aug 2009
    Posts
    16

    Default Re: Automatically Import email into sugarcrm

    Add me to the list also. This manual import is a royal pain.

  7. #7
    colbert is offline Junior Member
    Join Date
    Oct 2010
    Posts
    4

    Thumbs down Re: Automatically Import email into sugarcrm

    Same here :-( Surely they need to do something about this it even happens on the latest version

  8. #8
    BiztechDev's Avatar
    BiztechDev is offline Senior Member
    Join Date
    Sep 2010
    Location
    India
    Posts
    136

    Cool Re: Automatically Import email into sugarcrm

    Hi ive modified some code to import the mail to sugar and attach to the case based on case no. within the subject line, when u click the "Check Mail" u modify based on ur requirement.

    changed modules/inboundEmail/InboundEmail.php
    ======================================
    importOneEmail function
    ======================================
    added this code to attach mail to the case and save the comment passed in the mail to case(myown functionality u may ommit this)


    Code:
             if (!empty($_REQUEST['parent_id']) && !empty($_REQUEST['parent_type'])) {
                    $email->parent_id = $_REQUEST['parent_id'];
                    $email->parent_type = $_REQUEST['parent_type'];
                    $mod = strtolower($email->parent_type);
                    $email->load_relationship($mod);
                    $email->$mod->add($email->parent_id);
                    if($_REQUEST['parent_type']=='Cases')
                    {
                         if(!class_exists('aCase')) {
                            require_once('modules/Cases/Case.php');
                        }
                        $c = new aCase();
                        if($caseId = InboundEmail::getCaseIdFromCaseNumber($email->custom_fields->bean->name, $c)) {
                            
                            $c->retrieve($caseId);
                            $c->load_relationship('emails');
                            $c->emails->add($this->id);
                            $this->parent_type = "Cases";
                            $this->parent_id = $caseId;  
                        
                            //to save the comment from email...
                            global $db;
                            $cid=create_guid();
                            if($email->description!="")
                            {   $creator=($email->contact_name) ? $email->from_addr_name : $email->from_addr;
                                $db->query("insert into comments(id,case_id,comment,created,creator_name)values('{$cid}','{$caseId}','{$email->description}',NOW(),'{$creator}')");
                            }
                        } // if
                
                    }
             }
             
             //now if redirected from check email progress then parent_id and type is blank so hv to assign manually
             if(empty($_REQUEST['parent_type']))
                {
                        if(!class_exists('aCase')) {
                            require_once('modules/Cases/Case.php');
                        }
                        $c = new aCase();
                        if($caseId = InboundEmail::getCaseIdFromCaseNumber($email->custom_fields->bean->name, $c)) {
                            
                            $c->retrieve($caseId);
                            $c->load_relationship('emails');
                            $c->emails->add($this->id);
                            $this->parent_type = "Cases";
                            $this->parent_id = $caseId;  
                            //change by bc 5_4_11 
                            //to save the comment from email...
                            global $db;
                            $cid=create_guid();
                            if($email->description!="")
                            {   $creator=($email->contact_name) ? $email->from_addr_name : $email->from_addr;
                                $db->query("insert into comments(id,case_id,comment,created,creator_name,modified_user)values('{$cid}','{$caseId}','{$email->description}',NOW(),'{$creator}','{$creator}')");
                            }
                        } // if
                
                }
    ================================================== ===============================

    then
    ======================================
    handleCaseAssignment function
    =====================================

    Code:
    function handleCaseAssignment(&$email) {
    		if(!class_exists('aCase')) {
    			require_once('modules/Cases/Case.php');
    		}
    		$c = new aCase();
    		if($caseId = $this->getCaseIdFromCaseNumber($email->name, $c)) {
    
    
    
    			$c->retrieve($caseId);
    			$c->load_relationship('emails');
    			$c->emails->add($email->id);
    
    			$email->retrieve($email->id);
    			$email->parent_type = "Cases";
    			$email->parent_id = $caseId;
    			// assign the email to the case owner
    			if(array_key_exists('email', get_defined_vars()))
                    {
                        if(array_key_exists('assigned_user_id', get_defined_vars()))
                            {
                                $email->$assigned_user_id = $c->assigned_user_id;
                            }
                    }
                    
    			$email->save();
    			$GLOBALS['log']->debug('InboundEmail found exactly 1 match for a case: '.$c->name);
    			return true;
    		} // if
    		return false;
    	} // fn
    ================================================== ========

    changed modules/Email/EmailUIAjax.php

    Code:
    case "checkEmailProgress":
            debugbreak();
            $GLOBALS['log']->info("[EMAIL] - Start checkEmail action for user [{$current_user->user_name}]");
            if(isset($_REQUEST['ieId']) && !empty($_REQUEST['ieId'])) {
                $ie->retrieve($_REQUEST['ieId']);
                $ie->mailbox = (isset($_REQUEST['mbox']) && !empty($_REQUEST['mbox'])) ? $_REQUEST['mbox'] : "INBOX";
                $synch = (isset($_REQUEST['synch']) && ($_REQUEST['synch'] == "true"));
                if ($ie->protocol == "pop3") {
                    $return = $ie->pop3_checkPartialEmail($synch);
                } else {
                    $return = $ie->checkEmailIMAPPartial(false, $synch);
                }
                $return['ieid'] = $ie->id;
                $return['synch'] = $synch;
               // echo $json->encode($return);
               
    //================================================================================================adde this code copied from the importEmail case
    
    
                 $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: importEmail");
                 $ie->retrieve($_REQUEST['ieId']);
                 $ie->mailbox = $_REQUEST['mbox'];
                 $ie->connectMailserver();
                 $return = array();
                 $status = true;
                 $count = 1;
                 global $current_user;
                 global $db;
                 $res=$db->query("select * from email_cache where ie_id='{$_REQUEST['ieId']}' and seen='0'");
                 while($data=$db->fetchByAssoc($res)){
                 if(strpos($data['imap_uid'], $app_strings['LBL_EMAIL_DELIMITER']) !== false) {
                        $exUids = explode($app_strings['LBL_EMAIL_DELIMITER'], $_REQUEST['imap_uid']);
                        foreach($exUids as $msgNo) {
                            $uid = $msgNo;
                            if($ie->protocol == 'imap') {
                                $msgNo = imap_msgno($ie->conn, $msgNo);
                                $status = $ie->importOneEmail($msgNo, $uid);
                            } else {
                                $status = $ie->importOneEmail($ie->getCorrectMessageNoForPop3($msgNo), $uid);
                            } // else
                            $return[] = "Message No " . $count . ", Status : " . ($status ? "Import Passed." : "Import Failed because either the message is already imported or deleted from server");
                            $count++;
                            if(($_REQUEST['delete'] == 'true') && $status && ($current_user->is_admin == 1 || $ie->group_id == $current_user->id)) {
                                $ie->deleteMessageOnMailServer($_REQUEST['uid']);
                                $ie->deleteMessageFromCache($_REQUEST['uid']);
                            } // if
                        } // for
                    } else {
                        
                        $msgNo = $data['imap_uid'];
                        if($ie->protocol == 'imap') {
                            $msgNo = imap_msgno($ie->conn, $data['imap_uid']);
                            $status = $ie->importOneEmail($msgNo, $data['imap_uid']);
                        } else {
                            $status = $ie->importOneEmail($ie->getCorrectMessageNoForPop3($msgNo), $data['imap_uid']);
                        } // else
                        $return[] = "Message No " . $count . ", Status : " . ($status ? "Import Passed." : "Import Failed because the message is already imported or deleted from server");
                        
                        if(($_REQUEST['delete'] == 'true') && $status && ($current_user->is_admin == 1 || $ie->group_id == $current_user->id)) {
                            $ie->deleteMessageOnMailServer($data['imap_uid']);
                            $ie->deleteMessageFromCache($data['imap_uid']);
                        } // if
                    } // else
                 }
                    echo $json->encode($return);
                    break;               
                //================================================================================================
            } // if
            break;
    Last edited by BiztechDev; 2011-04-06 at 09:49 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Email management - Improvements in future releases
    By manoj in forum Feature Requests
    Replies: 102
    Last Post: 2009-11-17, 06:43 AM
  2. Enable Logging
    By vidtechsteve in forum Help
    Replies: 12
    Last Post: 2009-11-09, 02:54 PM
  3. Auto-Reply doesnt send the email...
    By adaml in forum Help
    Replies: 1
    Last Post: 2007-07-12, 11:50 AM
  4. Replies: 61
    Last Post: 2006-10-22, 08:40 AM
  5. Installs ok but errors and crashing of app
    By NiallH in forum General Discussion
    Replies: 7
    Last Post: 2006-01-21, 06:11 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
  •