Automatic Email Import issue

Hello , i am new to suite crm and we are trying to implement it to import emails automatically.

From what we have checked in a Group account the crm does import of email that are real email or distribution lists and it marks them as imported. The records are created in the database but from we see there is a problem.

If you try to open the email it is empty though the email is visible in the timeline page of any contact, account , module record the crm identifies based on the “to:” variable of the email.

Also it immediatly “Assigned To” field/column in the List View of the Email module place them all to admin.

I was expecting that we can implement a workflow that can find these emails based on current assignment or cause parent_type and parent_id are not set ( i assume that these are the fields set when the user imports manually the email)

And update the values of all:

  • Assigned To ( Search email-receivers emails into the user-accounts and set the assigned To to the first user identified)
  • Parent Type ( The module where the email-receivers emails is identified with the module email)
  • Parent Id ( to the id of the record where the email-senders emails is equal)

This to be done from workflow in user interface.
I do not see or did not understand how to set a value to relative object record based on dynamic filter.
Even the Relationship function is not clear in the documentation what it really does. Does it really set the relationship and in this case what should be selected to connect the Email to an existing Contact?
I have tried to use


but it does not work.

I do not also see the Related to field to be able to be selected in the list of set of a field

Another thing from what i saw if you try to make a relationship you can not select the relationship dynamically based on the sender (if the sender exists as contact,account…) but you have to select manually


In this case though in db you are creating a email_bean record that connects the bean=Contact and the bean_id to the email_id and cause of this you can see the email record to the specific contact.
Though if you import the email where you select the Related To: then you are setting the parent_id variable to a specific id for the contact table (contact.id) .

In this case the relationship inside workflow is not at all the same with the import of the email and the related to field

I’m not totally understanding what you are trying to do, but it sounds too complex for Workflow. You might want to write a logic hook to achieve what you are trying to do. I don’t totally understand what your trigger, is, but you could do it on save of an email, or on save of the case creation or after relationship add between the case and the email.

In this post you are discussing almost the same topic and you refer about a function that probably needs to be used inside a loop in a specific file. There there is discussion about how the software needs to work on the email import but there is no conclusion if this is implemented and released. Or what should be the solution for the import

Importing emails automatically - :package: Install & Upgrade Help - SuiteCRM

I don’t believe anyone fixed this. You might want to try a custom logic hook to do what you need. I don’t think you’re going to get there with workflow.

i need something simple. TO import only the emails that are sent from to crm contacts or crm users or received by contact / crm users.
The rest of the emails do not need to be imported

This currently doesn’t exist in SuiteCRM. You’ll have to code it yourself with a logic hook.

If i try to code it i need to know what the import does exactly does it go only to set the parent type and the parent email einai the email module? or it does some thing else also?

From which module to get contacts and accounts emails and who?

I am asking cause i ma not close to php i am more c++ and java related so i have to cover some ground and any help would be usefull

Hey @Kyriakos I don’t have any pre-written script for this. But basically I would think when a new record gets created in your email account (maybe a before save hook would work). Probably want to key on the “to address” you want to search leads and contacts for the “from” email address and if it exists, create a relationship from the email to the contact/lead. You might also want to create a relationship to the account which the contact belongs to (I can’t remember if this happens automatically to show up in the account history based on the email being from a contact of that account or not).

Unfortunately i need to know what the manual import saves first. Not the how (how it searches and identifies records) but what does it save. Does it go only to email record and saves whatever it wants in Parent Type and Parent ID or it creates also a record in email bean. It seems that it does not do both things. But it needs to be recorded somewhere. After this i can make something to utilize API or the logic hook to set the same variables and automatically update what i want. If i do not know what the official import does on db / record level when the user manually imports an email and connects it to some module and record then i can not start and do anything. I will have to reverse engineer this thing which i would like to avoid.

@Kyriakos I don’t know the sequence of events of the top of my head. I do know the case import feature does work properly and imports and attaches records. You might want to set that up and follow through what it does and you can try to replicate it. You might even be able to copy some of the code.

I can agree that automation of import of emails create records but as you have said before it does not make the proper connection to "related to " field as the manual import does. It seams that i will have to try to reverse engineer what is really happening in the manual import to identify what i need to fix there for the automatic imports.

After some test. I did sent an email in the group Inbound Email account and it was imported automatically and then i just imported it manually to check what are the db record changes.

The changes that i have seen in the email table are:

Email Imported Automatically from Group Account
date_modified modified_user_id assigned_user_id orphaned flagged reply_to_status parent_type parent_id
2024-11-27 21:19 1 1 \N \N \N \N \N
Same Email after re-Importing Manually
date_modified modified_user_id assigned_user_id orphaned flagged reply_to_status parent_type parent_id
2024-11-27 21:29 4c373023-5aeb-1c86-e3df-67375a4f2a09 52448b8d-95ea-2d32-b926-67361b7ad48b 0 0 0 Contacts cb1000c4-942e-9d00-7395-673f3fc1aa44

Is there any explanation what are the columns : orphaned , flagged, reply_to_status that are updated to zero while in the initial automated import where NULL? For the rest i think it is easy to update if you identify proper IDs from other modules.