Attachments - Not copying across to Suite

Hi guys,

I have just installed the Outlook 2013 plugin (v1.1.0.9) and am able to sync emails across to SuiteCRM, but the attachments (e.g. .pdf files) are not copying across. Is there a trouble shooting guide to resolve this issue?

I have ticked the “Archive attachments also” box in the Archive tab (see attachment), but they’re still not coming across to SuiteCRM.

*bump

Are they not coming over at all or are they corrupt? There is a known bug (not sure if it has been patched yet) which caused attachments to be corrupted.

They’re not coming across at all… the email syncs ok, but the attachment does not.

bump

is anyone able to guide me through troubleshooting?

You can check your logs:
suitecrm.log
php-errors.log (you need to turn on logging PHP errors in php.ini, Google how to do it)

You can also check the permissions on the directory onto which the attachments get copied. I’m afraid I don’t know which directory it is, probably “upload”.

Finally, if you have a debugger you can step through the code and try to see where it breaks.

Is anyone able to confirm the directory into which the attachments get copied, as per pgr’s suggestion below?

Hello

maybe you can find that out using other attachments. I mean, from other emails where attachments are working, not from the Outlook plugin.

I know what happens for the “Photos” fields, and for the Documents module. These probably (just probably) use a similar mechanism to email attachments. Basically, files get copied over to “upload” directory (mine is called “1711-upload”, I have no idea why), using names like f3f830d9-94fe-b838-45ae-56a00963e3dc_photo which are made up from the id of the corresponding SuiteCRM record. These ids are the ones you find in the database.

Documents use a similar method, slightly more complicated because there is an additional level of indirection to support multiple document “revisions” (see my post here https://suitecrm.com/forum/suitecrm-7-0-discussion/9106-mass-importation-of-attachments#31426).

I’m sure that if you peek in the database to see the tables relating to email attachments, you can find the ids and look for those files in the file system.

Good luck.

I got curious about this and decided to investigate. This is what I found:

So, to see all the attachment files on your system, run this in MySql:

SELECT notes.id, emails.id, filename, file_mime_type FROM notes INNER JOIN emails ON notes.parent_type = 'Emails' AND notes.parent_id = emails.id INNER JOIN emails_text ON emails.id = emails_text.email_id

That filename shown by this query is the filename as seen by the user.

The actual file on your system will be in the “upload” directory, with a name equal to the first id show (that of the note record).

You can pull other fields from the “Notes” and “Emails” tables, if you need (recipients, sender, date, etc.).

I hope this helps.

Thanks for looking into this.

I tried running the script you provided, but unfortunately it came back with an empty result.

The process I followed was:

  1. Log into phpMyAdmin
  2. Select the database from the LHS
  3. Click on SQL tab
  4. Enter the script exactly as provided & click Go.

I then receive the following response - “MySQL returned an empty result set (i.e. zero rows). (Query took 0.0049 sec)”.

Am i doing something wrong?

Well, maybe you don’t have any actual data currently there? Are there any attachments in your emails?

You can try simpler queries just to make sure you’re accessing the correct database:

SELECT * FROM emails

SELECT * FROM notes

I’m assuming you will find that your sync to Outlook is generating rows in the “emails” table (otherwise you wouldn’t see any emails in SuiteCRM at all).

If nothing is showing in the “notes” table, then you know that the process of importing attachments is failing at the database level, not just the copying of the files over into the file system.

If that is the case, I don’t know what else could be done, short of debugging the plugin. It’s strange if that fails without any sign in the logs…

I ran the following command in SQL, "SELECT * FROM emails ", and confirmed that I am running it on the correct database and there is in fact data there. Prior to running the query though, I identified a contact to whom I have successfully archived an email via the Outlook plugin, which also contained an attachment (screenshot attached).

I was then able to locate this entry in the database using the command above… and whilst there is an entry for the Subject Header in the database, there does not appear to be any entry for the uploaded / attached file.

Should I be expecting to find an entry for the attachment when I run this query as well?

You’re not supposed to find anything else in the “emails” table, it looks correct.

But in the “notes” table, you’re supposed to find a record with parent_id equaling your email record.

You can look for it with something similar to this:
SELECT * FROM notes where parent_id=‘69020c4e-2e43-31f3-2a1c-5739daec6c10’

(replace that with your ID 37470…etc…, I didn’t bother to copy the whole thing from your image).

If you do find that row in “notes”, then the “id” of that row will be the name of the file you should find in your upload directory.

I’ve found a record in the “notes” table with the same parent_id as that of the email record.

I’ve attached a screenshot of the details and believe the “id” number I should be looking for in the uploads file is “83a6fa16-b73e-652e-17d9-57383bb55055”.

Is that correct?

Correct… but it would be faster to just look in the directory than to type all that to ask me! : - )

Still, this doesn’t really help you solve the problem of why the Outlook synchronization isn’t working to create the attachments in SuiteCRM…

1 Like

Lol… yes, I agree.

I have found the file in the directory and can confirm that my folder is simply called, “Uploads”.

As you said though, it still doesn’t explain why the files are not copied across via the Outlook plugin on my machine at work.

Now you understand the process, so you can try to see which parts are working, and which aren’t. See if you get a record created in the database in “emails”; then see if you get a corresponding record in “notes”; then check to see if the file is actually there.

Maybe this can give you clues and let you try different things (check permissions on the upload directory), try different filenames and extensions, etc.

I know that some extensions are not uploaded “as they are” to the upload directory for security reasons (I think php files get their named changed, for example).

Thanks pgr,
I’ve archived an email containing an attachment into SuiteCRM this morning at work and as expected, the attachment didn’t copy across.

I’ve followed the process we outlined last night and identified that when archiving emails containing attachments at work, the “Email” record in the database contains data in the assigned_user_id field, whereas when i archive an email containing an attachment at home, no data is copied into the assigned_user_id field.

I’ve attached a couple of screenshots highlighting the additional data in the assigned_user_id field, which I can only assume is causing the attachment not to copy across, but I am unable to reconcile why this may be the case… or more importantly, how to resolve it.

Can you point me in the right direction?

I’m sorry, I don’t have much time today, but regarding the attachment that did NOT copy correctly…

  • do you have a corresponding record in the “notes” table?
  • if you do, do you have the file in the upload directory, with permissions set correctly?

That’s what seems crucial to me.

The “user assignment” might influence whether a certain document is visible to you or not; but it’s no good checking that unless you know for sure that the database has a reference for it, and the file is there.