Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label Creation & Skipping Issue #31

Closed
hbmike opened this issue Oct 10, 2017 · 3 comments
Closed

Label Creation & Skipping Issue #31

hbmike opened this issue Oct 10, 2017 · 3 comments

Comments

@hbmike
Copy link

hbmike commented Oct 10, 2017

I suspect I am having some label creation and skipping issues due to the structure of the .mbox files.. I would love to get your feedback.

When I run the import-mailbox-to-gmail script, I noticed 2 main things:

  1. The below 4 mbox labels are not created in Gmail. Instead individual labels for each .emlx file are created.
  2. The emails themselves are not being uploaded (messages or attachments).

I basically have 4 .mbox "files" which I copied from the Apple Mail library. I only want these to be uploaded to Gmail under these labels for one particular account - user1@domain.com
Deleted Messages.mbox
Drafts.mbox
INBOX.mbox
Sent Messages.mbox

I have these mbox files stored in the following directory:
C:\mbox\user1@domain.com

I'm not sure how .mbox should be structured for this script to work. When I open up any of the above .mbox "files", there is a sub-folder structure of info.plist, a Messages folder (.emlx files) and an Attachments folder (raw files).

I also had a look at the log and posted below all warnings, errors and (sample) skipping I found.
It would be great to get your input and your suggestions for fixing. Thanks so much.

WARNING autodetect@init.py file_cache is unavailable when using oauth2client >= 4.0.0
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery_cache/init.py", line 41, in autodetect
    from . import file_cache
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in
    'file_cache is unavailable when using oauth2client >= 4.0.0')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0

ERROR get_label_id_from_name@import-mailbox-to-gmail.py Can't create label 'Drafts' for user user1@domain.com
Traceback (most recent call last):
  File "/Users/accounts/Documents/user/gmail_import_files/import-mailbox-to-gmail.py", line 153, in get_label_id_from_name
    body=label_object).execute(num_retries=args.num_retries)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleapiclient/http.py", line 842, in execute
    raise HttpError(resp, content, uri=self.uri)
HttpError: <HttpError 400 when requesting https://www.googleapis.com/gmail/v1/users/user1%40domain.com/labels?alt=json returned "Invalid label name">
15:35:47 ERROR process_mbox_files@import-mailbox-to-gmail.py Labels under 'Drafts.mbox' may not nest correctly
15:35:47 INFO process_mbox_files@import-mailbox-to-gmail.py Skipping '/Users/accounts/Documents/user1/mbox/user1@domain.com/.DS_Store' because it doesn't have a .mbox extension
15:35:47 INFO process_mbox_files@import-mailbox-to-gmail.py Skipping '/Users/accounts/Documents/user/mbox/user1@domain.com/Deleted Messages.mbox/.DS_Store' because it doesn't have a .mbox extension
15:35:47 INFO process_mbox_files@import-mailbox-to-gmail.py Skipping '/Users/accounts/Documents/user/mbox/user1@domain.com/Deleted Messages.mbox/Info.plist' because it doesn't have a .mbox extension

15:35:47 INFO main@import-mailbox-to-gmail.py Done importing user user1@domain.com. Labels: 0 succeeded, 0 with some errors, 0 failed. Messages: 0 succeeded, 0 failed.
15:35:47 INFO main@import-mailbox-to-gmail.py *** Done importing all users from directory '/Users/accounts/Documents/user/mbox'
15:35:47 INFO main@import-mailbox-to-gmail.py *** Import summary:
15:35:47 INFO main@import-mailbox-to-gmail.py     1 users imported with no failures
15:35:47 INFO main@import-mailbox-to-gmail.py     0 users imported with some failures
15:35:47 INFO main@import-mailbox-to-gmail.py     0 users failed
15:35:47 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with no failures
15:35:47 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) imported with some failures
15:35:47 INFO main@import-mailbox-to-gmail.py     0 labels (mbox files) failed
15:35:47 INFO main@import-mailbox-to-gmail.py     0 messages imported successfully
15:35:47 INFO main@import-mailbox-to-gmail.py     0 messages failed

@eesheesh
Copy link
Collaborator

Are there mbox "files" from Apple Mail?

If so, the way to convert them to standard mbox files (that this script can handle) is by right clicking the folder in Apple Mail and choosing "Export Mailbox". This creates file folders named foldername.mbox with a file named "mbox" inside of them, that import-mailbox-to-gmail can handle.

I've never heard of .emlx files before, a quick Google search found that this is a format used by some versions of Apple Mail. I hope you can still open them in Apple Mail and export as I suggested. Apple Mail 10.3 (on macOS Sierra 10.12.6) produces the export format described above, that should work with this script.

I hope this helps! Please let me know if it worked. :)

@hbmike
Copy link
Author

hbmike commented Oct 12, 2017

Thank you. Yes, it worked once I exported the emails from the Apple Mail "Export Mailbox".

Previously, I was taking the files from the Apple Mail Library directly to avoid some issues I'd been having with the export.

It's all working now. Thank you once again :)

@eesheesh
Copy link
Collaborator

Thanks for confirming! :) I updated the instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants